[][src]Struct ckb_reward_calculator::RewardCalculator

pub struct RewardCalculator<'a, CS> {
    pub consensus: &'a Consensus,
    pub store: &'a CS,
}

Fields

consensus: &'a Consensusstore: &'a CS

Implementations

impl<'a, CS: ChainStore<'a>> RewardCalculator<'a, CS>[src]

pub fn new(consensus: &'a Consensus, store: &'a CS) -> Self[src]

pub fn block_reward_to_finalize(
    &self,
    parent: &HeaderView
) -> Result<(Script, BlockReward), Error>
[src]

RewardCalculator is used to calculate block finalize target's reward according to the parent header. block reward consists of four parts: base block reward, tx fee, proposal reward, and secondary block reward.

pub fn block_reward_for_target(
    &self,
    target: &HeaderView
) -> Result<(Script, BlockReward), Error>
[src]

pub fn txs_fees(&self, target: &HeaderView) -> Result<Capacity, Error>[src]

Miner get (tx_fee - 40% of tx fee) for tx commitment. Be careful of the rounding, tx_fee - 40% of tx fee is different from 60% of tx fee.

pub fn proposal_reward(
    &self,
    parent: &HeaderView,
    target: &HeaderView
) -> Result<Capacity, Error>
[src]

Earliest proposer get 40% of tx fee as reward when tx committed block H(19) target H(13) ProposalWindow(2, 5) target current / / 10 11 12 13 14 15 16 17 18 19 \ \ \ _///__/ \ \ _/// \ _// _______/

Auto Trait Implementations

impl<'a, CS> RefUnwindSafe for RewardCalculator<'a, CS> where
    CS: RefUnwindSafe

impl<'a, CS> Send for RewardCalculator<'a, CS> where
    CS: Sync

impl<'a, CS> Sync for RewardCalculator<'a, CS> where
    CS: Sync

impl<'a, CS> Unpin for RewardCalculator<'a, CS>

impl<'a, CS> UnwindSafe for RewardCalculator<'a, CS> where
    CS: RefUnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> AsAny for T where
    T: Any

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Erased for T

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Err = <U as TryFrom<T>>::Err

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,