fn create_proposer_election(
        &self,
        epoch_state: &EpochState,
    ) -> Box<dyn ProposerElection + Send + Sync> {
        let proposers = epoch_state
            .verifier
            .get_ordered_account_addresses_iter()
            .collect::<Vec<_>>();
        match &self.config.proposer_type {
            ConsensusProposerType::RotatingProposer => Box::new(RotatingProposer::new(
                proposers,
                self.config.contiguous_rounds,
            )),
            // We don't really have a fixed proposer!
            ConsensusProposerType::FixedProposer => {
                let proposer = choose_leader(proposers);
                Box::new(RotatingProposer::new(
                    vec![proposer],
                    self.config.contiguous_rounds,
                ))
            }
            ConsensusProposerType::LeaderReputation(heuristic_config) => {
                let backend = Box::new(LibraDBBackend::new(
                    proposers.len(),
                    self.storage.libra_db(),
                ));
                let heuristic = Box::new(ActiveInactiveHeuristic::new(
                    heuristic_config.active_weights,
                    heuristic_config.inactive_weights,
                ));
                Box::new(LeaderReputation::new(proposers, backend, heuristic))
            }
            ConsensusProposerType::RoundProposer(round_proposers) => {
                // Hardcoded to the first proposer
                let default_proposer = proposers.get(0).unwrap();
                Box::new(RoundProposer::new(
                    round_proposers.clone(),
                    *default_proposer,
                ))
            }
        }
    }
/// Create a proposer election handler based on proposers
Create a proposer election handler based on proposers
Create a proposer election handler based on proposers
fn create_proposer_election(
        &self,
        epoch_state: &EpochState,
    ) -> Box<dyn ProposerElection + Send + Sync> {
        let proposers = epoch_state
            .verifier
            .get_ordered_account_addresses_iter()
            .collect::<Vec<_>>();
        match &self.config.proposer_type {
            ConsensusProposerType::RotatingProposer => Box::new(RotatingProposer::new(
                proposers,
                self.config.contiguous_rounds,
            )),
            // We don't really have a fixed proposer!
            ConsensusProposerType::FixedProposer => {
                let proposer = choose_leader(proposers);
                Box::new(RotatingProposer::new(
                    vec![proposer],
                    self.config.contiguous_rounds,
                ))
            }
            ConsensusProposerType::LeaderReputation(heuristic_config) => {
                let backend = Box::new(LibraDBBackend::new(
                    proposers.len(),
                    self.storage.libra_db(),
                ));
                let heuristic = Box::new(ActiveInactiveHeuristic::new(
                    heuristic_config.active_weights,
                    heuristic_config.inactive_weights,
                ));
                Box::new(LeaderReputation::new(proposers, backend, heuristic))
            }
            ConsensusProposerType::RoundProposer(round_proposers) => {
                // Hardcoded to the first proposer
                let default_proposer = proposers.get(0).unwrap();
                Box::new(RoundProposer::new(
                    round_proposers.clone(),
                    *default_proposer,
                ))
            }
        }
    }
fn create_proposer_election ( & self , epoch_state : & EpochState , ) -> Box < dyn ProposerElection + Send + Sync > { let proposers = epoch_state . verifier . get_ordered_account_addresses_iter ( ) . collect :: < Vec < _ > > ( ) ; match & self . config . proposer_type { ConsensusProposerType :: RotatingProposer => Box :: new ( RotatingProposer :: new ( proposers , self . config . contiguous_rounds , ) ) , // We don't really have a fixed proposer! ConsensusProposerType :: FixedProposer => { let proposer = choose_leader ( proposers ) ; Box :: new ( RotatingProposer :: new ( vec ! [ proposer ] , self . config . contiguous_rounds , ) ) } ConsensusProposerType :: LeaderReputation ( heuristic_config ) => { let backend = Box :: new ( LibraDBBackend :: new ( proposers . len ( ) , self . storage . libra_db ( ) , ) ) ; let heuristic = Box :: new ( ActiveInactiveHeuristic :: new ( heuristic_config . active_weights , heuristic_config . inactive_weights , ) ) ; Box :: new ( LeaderReputation :: new ( proposers , backend , heuristic ) ) } ConsensusProposerType :: RoundProposer ( round_proposers ) => { // Hardcoded to the first proposer let default_proposer = proposers . get ( 0 ) . unwrap ( ) ; Box :: new ( RoundProposer :: new ( round_proposers . clone ( ) , * default_proposer , ) ) } } }
Create a proposer election handler based on proposers
Create a proposer election handler based on proposers
&self
epoch_state
&EpochState
&self
epoch_state
&EpochState