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§
Sourcefn restrict_vote(
&self,
backend: Arc<B>,
base: &Block::Header,
best_target: &Block::Header,
current_target: &Block::Header,
) -> VotingRuleResult<Block>
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,
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>
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