pub trait VotingRule<Block, B>: DynClone + Send + Syncwhere
    Block: BlockT,
    B: HeaderBackend<Block>,{
    // Required method
    fn restrict_vote(
        &self,
        backend: Arc<B>,
        base: &Block::Header,
        best_target: &Block::Header,
        current_target: &Block::Header
    ) -> VotingRuleResult<Block>;
}
Expand description

A trait for custom voting rules in GRANDPA.

Required Methods§

source

fn restrict_vote( &self, backend: Arc<B>, base: &Block::Header, best_target: &Block::Header, current_target: &Block::Header ) -> VotingRuleResult<Block>

Restrict the given current_target vote, returning the block hash and number of the block to vote on, and None in case the vote should not be restricted. base is the block that we’re basing our votes on in order to pick our target (e.g. last round estimate), and best_target is the initial best vote target before any vote rules were applied. When applying multiple VotingRules both base and best_target should remain unchanged.

The contract of this interface requires that when restricting a vote, the returned value must be an ancestor of the given current_target, this also means that a variant must be maintained throughout the execution of voting rules wherein current_target <= best_target.

Trait Implementations§

source§

impl<Block, B> VotingRule<Block, B> for Box<dyn VotingRule<Block, B>>where Block: BlockT, B: HeaderBackend<Block>, Self: Clone,

source§

fn restrict_vote( &self, backend: Arc<B>, base: &Block::Header, best_target: &Block::Header, current_target: &Block::Header ) -> VotingRuleResult<Block>

Restrict the given current_target vote, returning the block hash and number of the block to vote on, and None in case the vote should not be restricted. base is the block that we’re basing our votes on in order to pick our target (e.g. last round estimate), and best_target is the initial best vote target before any vote rules were applied. When applying multiple VotingRules both base and best_target should remain unchanged. Read more

Implementations on Foreign Types§

source§

impl<Block, B> VotingRule<Block, B> for ()where Block: BlockT, B: HeaderBackend<Block>,

source§

fn restrict_vote( &self, _backend: Arc<B>, _base: &Block::Header, _best_target: &Block::Header, _current_target: &Block::Header ) -> VotingRuleResult<Block>

source§

impl<Block, B> VotingRule<Block, B> for Box<dyn VotingRule<Block, B>>where Block: BlockT, B: HeaderBackend<Block>, Self: Clone,

source§

fn restrict_vote( &self, backend: Arc<B>, base: &Block::Header, best_target: &Block::Header, current_target: &Block::Header ) -> VotingRuleResult<Block>

Implementors§

source§

impl<Block, B> VotingRule<Block, B> for BeforeBestBlockBy<NumberFor<Block>>where Block: BlockT, B: HeaderBackend<Block>,

source§

impl<Block, B> VotingRule<Block, B> for ThreeQuartersOfTheUnfinalizedChainwhere Block: BlockT, B: HeaderBackend<Block>,