remove From::from. (#8390)

* Some tiny modifications.
1. fix some typo in the comment.
2. sort the order of methods in 'impl state::Backend for StateDB`

* Remove the clone of code_cache, as it has been done in clone_basic.

* remove From::from. It seems not necessary.
This commit is contained in:
lihuafeng 2018-04-19 19:16:04 +08:00 committed by Marek Kotewicz
parent 14361cc7b1
commit 8fb47b52f5

12
ethcore/src/executive.rs Normal file → Executable file
View File

@ -237,27 +237,27 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
let base_gas_required = U256::from(t.gas_required(&schedule)); let base_gas_required = U256::from(t.gas_required(&schedule));
if t.gas < base_gas_required { if t.gas < base_gas_required {
return Err(From::from(ExecutionError::NotEnoughBaseGas { required: base_gas_required, got: t.gas })); return Err(ExecutionError::NotEnoughBaseGas { required: base_gas_required, got: t.gas });
} }
if !t.is_unsigned() && check_nonce && schedule.kill_dust != CleanDustMode::Off && !self.state.exists(&sender)? { if !t.is_unsigned() && check_nonce && schedule.kill_dust != CleanDustMode::Off && !self.state.exists(&sender)? {
return Err(From::from(ExecutionError::SenderMustExist)); return Err(ExecutionError::SenderMustExist);
} }
let init_gas = t.gas - base_gas_required; let init_gas = t.gas - base_gas_required;
// validate transaction nonce // validate transaction nonce
if check_nonce && t.nonce != nonce { if check_nonce && t.nonce != nonce {
return Err(From::from(ExecutionError::InvalidNonce { expected: nonce, got: t.nonce })); return Err(ExecutionError::InvalidNonce { expected: nonce, got: t.nonce });
} }
// validate if transaction fits into given block // validate if transaction fits into given block
if self.info.gas_used + t.gas > self.info.gas_limit { if self.info.gas_used + t.gas > self.info.gas_limit {
return Err(From::from(ExecutionError::BlockGasLimitReached { return Err(ExecutionError::BlockGasLimitReached {
gas_limit: self.info.gas_limit, gas_limit: self.info.gas_limit,
gas_used: self.info.gas_used, gas_used: self.info.gas_used,
gas: t.gas gas: t.gas
})); });
} }
// TODO: we might need bigints here, or at least check overflows. // TODO: we might need bigints here, or at least check overflows.
@ -268,7 +268,7 @@ impl<'a, B: 'a + StateBackend> Executive<'a, B> {
// avoid unaffordable transactions // avoid unaffordable transactions
let balance512 = U512::from(balance); let balance512 = U512::from(balance);
if balance512 < total_cost { if balance512 < total_cost {
return Err(From::from(ExecutionError::NotEnoughCash { required: total_cost, got: balance512 })); return Err(ExecutionError::NotEnoughCash { required: total_cost, got: balance512 });
} }
let mut substate = Substate::new(); let mut substate = Substate::new();