async fn add_vote(&mut self, vote: &Vote) -> anyhow::Result<()> {
        debug!("Add vote: {}", vote);
        let block_id = vote.vote_data().proposed().id();
        // Check if the block already had a QC
        if self
            .block_store
            .get_quorum_cert_for_block(block_id)
            .is_some()
        {
            return Ok(());
        }
        // Add the vote and check whether it completes a new QC or a TC
        let res = self
            .round_state
            .insert_vote(vote, &self.epoch_state.verifier);
        match res {
            VoteReceptionResult::NewQuorumCertificate(qc) => {
                // Note that the block might not be present locally, in which case we cannot calculate
                // time between block creation and qc
                if let Some(time_to_qc) = self.block_store.get_block(block_id).and_then(|block| {
                    duration_since_epoch()
                        .checked_sub(Duration::from_micros(block.timestamp_usecs()))
                }) {
                    counters::CREATION_TO_QC_S.observe_duration(time_to_qc);
                }

                self.new_qc_aggregated(qc, vote.author()).await
            }
            VoteReceptionResult::NewTimeoutCertificate(tc) => self.new_tc_aggregated(tc).await,
            _ => Ok(()),
        }
    }
/// Add a vote to the pending votes.
/// If a new QC / TC is formed then
/// 1) fetch missing dependencies if required, and then
/// 2) call process_certificates(), which will start a new round in return.
Add a vote to the pending votes.
If a new QC / TC is formed then
1) fetch missing dependencies if required, and then
2) call process_certificates(), which will start a new round in return.
Add a vote to the pending votes . If a new QC / TC is formed then 1 ) fetch missing dependencies if required and then 2 ) call process_certificates () which will start a new round in return .
async fn add_vote(&mut self, vote: &Vote) -> anyhow::Result<()> {
        debug!("Add vote: {}", vote);
        let block_id = vote.vote_data().proposed().id();
        // Check if the block already had a QC
        if self
            .block_store
            .get_quorum_cert_for_block(block_id)
            .is_some()
        {
            return Ok(());
        }
        // Add the vote and check whether it completes a new QC or a TC
        let res = self
            .round_state
            .insert_vote(vote, &self.epoch_state.verifier);
        match res {
            VoteReceptionResult::NewQuorumCertificate(qc) => {
                // Note that the block might not be present locally, in which case we cannot calculate
                // time between block creation and qc
                if let Some(time_to_qc) = self.block_store.get_block(block_id).and_then(|block| {
                    duration_since_epoch()
                        .checked_sub(Duration::from_micros(block.timestamp_usecs()))
                }) {
                    counters::CREATION_TO_QC_S.observe_duration(time_to_qc);
                }
                self.new_qc_aggregated(qc, vote.author()).await
            }
            VoteReceptionResult::NewTimeoutCertificate(tc) => self.new_tc_aggregated(tc).await,
            _ => Ok(()),
        }
    }
async fn add_vote ( & mut self , vote : & Vote ) -> anyhow :: Result < ( ) > { debug ! ( " " vote ) ; let block_id = vote . vote_data ( ) . proposed ( ) . id ( ) ; // Check if the block already had a QC if self . block_store . get_quorum_cert_for_block ( block_id ) . is_some ( ) { return Ok ( ( ) ) ; } // Add the vote and check whether it completes a new QC or a TC let res = self . round_state . insert_vote ( vote , & self . epoch_state . verifier ) ; match res { VoteReceptionResult :: NewQuorumCertificate ( qc ) => { // Note that the block might not be present locally, in which case we cannot calculate // time between block creation and qc if let Some ( time_to_qc ) = self . block_store . get_block ( block_id ) . and_then ( | block | { duration_since_epoch ( ) . checked_sub ( Duration :: from_micros ( block . timestamp_usecs ( ) ) ) } ) { counters :: CREATION_TO_QC_S . observe_duration ( time_to_qc ) ; } self . new_qc_aggregated ( qc , vote . author ( ) ) . await } VoteReceptionResult :: NewTimeoutCertificate ( tc ) => self . new_tc_aggregated ( tc ) . await , _ => Ok ( ( ) ) , } }
Add a vote to the pending votes.
Add a vote to the pending votes .
&mut self
vote
&Vote
&mut self
vote
&Vote