Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix up test fallout
  • Loading branch information
rphmeier committed May 11, 2018
commit 5f0dbd43e4e9eccf23f090c46c291f31a89a7b7b
51 changes: 21 additions & 30 deletions polkadot/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,7 @@ macro_rules! with_runtime {

$client.state_at(parent).map_err(Error::from).and_then(|state| {
let mut changes = Default::default();
let mut ext = state_machine::Ext {
overlay: &mut changes,
backend: &state,
};
let mut ext = state_machine::Ext::new(&mut changes, &state);

::substrate_executor::with_native_environment(&mut ext, || {
::runtime::Executive::initialise_block(&header);
Expand Down Expand Up @@ -280,49 +277,46 @@ impl<S: state_machine::Backend> ClientBlockBuilder<S>
{
// executes a extrinsic, inherent or otherwise, without appending to the list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

gah. bad comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://github.com/paritytech/polkadot/blame/513b544fb505b8c59f07adf10e8dc81de34d2a73/polkadot/api/src/lib.rs#L278

:)

(i remember this from the relevant PR but didn't bring it up then for some reason)

fn initialise_block(&mut self) -> Result<()> {
let mut ext = state_machine::Ext {
overlay: &mut self.changes,
backend: &self.state,
let result = {
let mut ext = state_machine::Ext::new(&mut self.changes, &self.state);
let h = self.header.clone();

::substrate_executor::with_native_environment(
&mut ext,
|| runtime::Executive::initialise_block(&h),
).map_err(Into::into)
};

let h = self.header.clone();

let result = ::substrate_executor::with_native_environment(
&mut ext,
|| runtime::Executive::initialise_block(&h),
).map_err(Into::into);

match result {
Ok(_) => {
ext.overlay.commit_prospective();
self.changes.commit_prospective();
Ok(())
}
Err(e) => {
ext.overlay.discard_prospective();
self.changes.discard_prospective();
Err(e)
}
}
}

// executes a extrinsic, inherent or otherwise, without appending to the list
fn apply_extrinsic(&mut self, extrinsic: UncheckedExtrinsic) -> Result<()> {
let mut ext = state_machine::Ext {
overlay: &mut self.changes,
backend: &self.state,
};
let result = {
let mut ext = state_machine::Ext::new(&mut self.changes, &self.state);

let result = ::substrate_executor::with_native_environment(
&mut ext,
move || runtime::Executive::apply_extrinsic(extrinsic),
).map_err(Into::into);
::substrate_executor::with_native_environment(
&mut ext,
move || runtime::Executive::apply_extrinsic(extrinsic),
).map_err(Into::into)
};

match result {
Ok(_) => {
ext.overlay.commit_prospective();
self.changes.commit_prospective();
Ok(())
}
Err(e) => {
ext.overlay.discard_prospective();
self.changes.discard_prospective();
Err(e)
}
}
Expand All @@ -344,10 +338,7 @@ impl<S: state_machine::Backend> BlockBuilder for ClientBlockBuilder<S>
}

fn bake(mut self) -> Block {
let mut ext = state_machine::Ext {
overlay: &mut self.changes,
backend: &self.state,
};
let mut ext = state_machine::Ext::new(&mut self.changes, &self.state);

let final_header = ::substrate_executor::with_native_environment(
&mut ext,
Expand Down
4 changes: 2 additions & 2 deletions substrate/client/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ mod tests {
let mut overlay = OverlayedChanges::default();

for tx in transactions.iter() {
let ret_data = execute(
let (ret_data, _) = execute(
backend,
&mut overlay,
&Executor::new(),
Expand All @@ -87,7 +87,7 @@ mod tests {
header = Header::decode(&mut &ret_data[..]).unwrap();
}

let ret_data = execute(
let (ret_data, _) = execute(
backend,
&mut overlay,
&Executor::new(),
Expand Down