pub fn append(&mut self, vote: Vote, committee: &Committee) -> ConsensusResult<Option<QC>> {
        let author = vote.author;
        // Ensure it is the first time this authority votes.
        ensure!(
            self.used.insert(author),
            ConsensusError::AuthorityReuseinQC(author)
        );
        self.votes.push((author, vote.signature));
        self.weight += committee.stake(&author);
        if self.weight >= committee.quorum_threshold() {
            self.weight = 0; // Ensures QC is only made once.
            return Ok(Some(QC {
                hash: vote.hash.clone(),
                view: vote.view,
                round: vote.round,
                height: vote.height,
                fallback: vote.fallback,
                proposer: vote.proposer,
                acceptor: vote.proposer,
                votes: self.votes.clone(),
            }));
        }
        Ok(None)
    }
/// Try to append a signature to a (partial) quorum.
Try to append a signature to a (partial) quorum.
Try to append a signature to a ( partial ) quorum .
pub fn append(&mut self, vote: Vote, committee: &Committee) -> ConsensusResult<Option<QC>> {
        let author = vote.author;
        // Ensure it is the first time this authority votes.
        ensure!(
            self.used.insert(author),
            ConsensusError::AuthorityReuseinQC(author)
        );
        self.votes.push((author, vote.signature));
        self.weight += committee.stake(&author);
        if self.weight >= committee.quorum_threshold() {
            self.weight = 0; // Ensures QC is only made once.
            return Ok(Some(QC {
                hash: vote.hash.clone(),
                view: vote.view,
                round: vote.round,
                height: vote.height,
                fallback: vote.fallback,
                proposer: vote.proposer,
                acceptor: vote.proposer,
                votes: self.votes.clone(),
            }));
        }
        Ok(None)
    }
pub fn append ( & mut self , vote : Vote , committee : & Committee ) -> ConsensusResult < Option < QC > > { let author = vote . author ; // Ensure it is the first time this authority votes. ensure ! ( self used insert ( author ) ConsensusError AuthorityReuseinQC ( author ) ) ; self . votes . push ( ( author , vote . signature ) ) ; self . weight += committee . stake ( & author ) ; if self . weight >= committee . quorum_threshold ( ) { self . weight = 0 ; // Ensures QC is only made once. return Ok ( Some ( QC { hash : vote . hash . clone ( ) , view : vote . view , round : vote . round , height : vote . height , fallback : vote . fallback , proposer : vote . proposer , acceptor : vote . proposer , votes : self . votes . clone ( ) , } ) ) ; } Ok ( None ) }
Try to append a signature to a (partial) quorum.
Try to append a signature to a ( partial ) quorum .
&mut self
vote
Vote
committee
&Committee
&mut self
vote
Vote
committee
&Committee