shorter constructor for externalities

This commit is contained in:
debris 2016-01-11 03:26:17 +01:00
parent 88409e7dbb
commit d1aadf456f
1 changed files with 7 additions and 2 deletions

View File

@ -229,7 +229,7 @@ impl<'a> Executive<'a> {
} }
} else if params.code.len() > 0 { } else if params.code.len() > 0 {
// if destination is a contract, do normal message call // if destination is a contract, do normal message call
let mut ext = Externalities::new(self.state, self.info, self.engine, self.depth, params, substate, OutputPolicy::Return(output)); let mut ext = Externalities::from_executive(self, params, substate, OutputPolicy::Return(output));
let evm = VmFactory::create(); let evm = VmFactory::create();
evm.exec(&params, &mut ext) evm.exec(&params, &mut ext)
} else { } else {
@ -247,7 +247,7 @@ impl<'a> Executive<'a> {
// then transfer value to it // then transfer value to it
self.state.transfer_balance(&params.sender, &params.address, &params.value); self.state.transfer_balance(&params.sender, &params.address, &params.value);
let mut ext = Externalities::new(self.state, self.info, self.engine, self.depth, params, substate, OutputPolicy::InitContract); let mut ext = Externalities::from_executive(self, params, substate, OutputPolicy::InitContract);
let evm = VmFactory::create(); let evm = VmFactory::create();
evm.exec(&params, &mut ext) evm.exec(&params, &mut ext)
} }
@ -324,6 +324,11 @@ impl<'a> Externalities<'a> {
output: output output: output
} }
} }
/// Creates `Externalities` from `Executive`.
pub fn from_executive(e: &'a mut Executive, params: &'a EvmParams, substate: &'a mut Substate, output: OutputPolicy<'a>) -> Self {
Self::new(e.state, e.info, e.engine, e.depth, params, substate, output)
}
} }
impl<'a> Ext for Externalities<'a> { impl<'a> Ext for Externalities<'a> {