pub trait ProposerSelector<A: ValidatorAddress>:
Clone
+ Send
+ Sync {
// Required method
fn select_proposer<'a>(
&self,
validator_set: &'a ValidatorSet<A>,
height: u64,
round: u32,
) -> &'a Validator<A>;
}Expand description
A trait for selecting the proposer for a given height and round.
This trait allows consumers to provide custom proposer selection logic instead of using the default round-robin approach. This is useful for implementing more sophisticated proposer selection algorithms like VRF-based selection, weighted selection, or other custom logic.
§Example Implementation
use pathfinder_consensus::*;
struct RoundRobinProposerSelector;
impl<A: ValidatorAddress> ProposerSelector<A> for RoundRobinProposerSelector {
fn select_proposer<'a>(
&self,
validator_set: &'a ValidatorSet<A>,
height: u64,
round: u32,
) -> &'a Validator<A> {
let index = round as usize % validator_set.count();
&validator_set.validators[index]
}
}Required Methods§
Sourcefn select_proposer<'a>(
&self,
validator_set: &'a ValidatorSet<A>,
height: u64,
round: u32,
) -> &'a Validator<A>
fn select_proposer<'a>( &self, validator_set: &'a ValidatorSet<A>, height: u64, round: u32, ) -> &'a Validator<A>
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.