Merge Machine and WithRewards (#10071)
This commit is contained in:
committed by
Afri Schoedon
parent
4d66e8d06d
commit
eea3de00c1
@@ -25,7 +25,7 @@ use std::sync::Arc;
|
||||
use hash::keccak;
|
||||
use error::Error;
|
||||
use machine::WithRewards;
|
||||
use parity_machine::{Machine, WithBalances};
|
||||
use parity_machine::Machine;
|
||||
use trace;
|
||||
use types::BlockNumber;
|
||||
use super::{SystemOrCodeCall, SystemOrCodeCallKind};
|
||||
@@ -152,7 +152,7 @@ impl BlockRewardContract {
|
||||
|
||||
/// Applies the given block rewards, i.e. adds the given balance to each beneficiary' address.
|
||||
/// If tracing is enabled the operations are recorded.
|
||||
pub fn apply_block_rewards<M: Machine + WithBalances + WithRewards>(
|
||||
pub fn apply_block_rewards<M: Machine + WithRewards>(
|
||||
rewards: &[(Address, RewardKind, U256)],
|
||||
block: &mut M::LiveBlock,
|
||||
machine: &M,
|
||||
|
||||
@@ -18,7 +18,7 @@ use engines::Engine;
|
||||
use engines::block_reward::{self, RewardKind};
|
||||
use ethereum_types::U256;
|
||||
use machine::WithRewards;
|
||||
use parity_machine::{Header, LiveBlock, WithBalances, TotalScoredHeader};
|
||||
use parity_machine::{Machine, Header, LiveBlock, TotalScoredHeader};
|
||||
use types::BlockNumber;
|
||||
|
||||
/// Params for a null engine.
|
||||
@@ -58,7 +58,7 @@ impl<M: Default> Default for NullEngine<M> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<M: WithBalances + WithRewards> Engine<M> for NullEngine<M>
|
||||
impl<M: Machine + WithRewards> Engine<M> for NullEngine<M>
|
||||
where M::ExtendedHeader: TotalScoredHeader,
|
||||
<M::ExtendedHeader as TotalScoredHeader>::Value: Ord
|
||||
{
|
||||
|
||||
@@ -437,14 +437,7 @@ impl ::parity_machine::Machine for EthereumMachine {
|
||||
type AncestryAction = ::types::ancestry_action::AncestryAction;
|
||||
|
||||
type Error = Error;
|
||||
}
|
||||
|
||||
impl<'a> ::parity_machine::LocalizedMachine<'a> for EthereumMachine {
|
||||
type StateContext = Call<'a>;
|
||||
type AuxiliaryData = AuxiliaryData<'a>;
|
||||
}
|
||||
|
||||
impl ::parity_machine::WithBalances for EthereumMachine {
|
||||
fn balance(&self, live: &ExecutedBlock, address: &Address) -> Result<U256, Error> {
|
||||
live.state().balance(address).map_err(Into::into)
|
||||
}
|
||||
@@ -454,6 +447,11 @@ impl ::parity_machine::WithBalances for EthereumMachine {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ::parity_machine::LocalizedMachine<'a> for EthereumMachine {
|
||||
type StateContext = Call<'a>;
|
||||
type AuxiliaryData = AuxiliaryData<'a>;
|
||||
}
|
||||
|
||||
/// A state machine that uses block rewards.
|
||||
pub trait WithRewards: ::parity_machine::Machine {
|
||||
/// Note block rewards, traces each reward storing information about benefactor, amount and type
|
||||
|
||||
Reference in New Issue
Block a user