pub fn append(
        &mut self,
        timeout: Timeout,
        committee: &Committee,
    ) -> ConsensusResult<Option<TC>> {
        let author = timeout.author;

        if self.used.contains(&author) {
            return Ok(None);
        }
        self.used.insert(author);

        // // Ensure it is the first time this authority votes.
        // ensure!(
        //     self.used.insert(author),
        //     ConsensusError::AuthorityReuseinTC(author)
        // );

        // Add the timeout to the accumulator.
        self.votes
            .push((author, timeout.signature, timeout.high_qc.round));
        self.weight += committee.stake(&author);
        let mut threshold = committee.quorum_threshold();
        if timeout.seq == 0 {
            threshold = committee.large_threshold();
        }
        if self.weight >= threshold {
            self.weight = 0; // Ensures TC is only created once.
            return Ok(Some(TC {
                seq: timeout.seq,
                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,
        timeout: Timeout,
        committee: &Committee,
    ) -> ConsensusResult<Option<TC>> {
        let author = timeout.author;
        if self.used.contains(&author) {
            return Ok(None);
        }
        self.used.insert(author);
        // // Ensure it is the first time this authority votes.
        // ensure!(
        //     self.used.insert(author),
        //     ConsensusError::AuthorityReuseinTC(author)
        // );
        // Add the timeout to the accumulator.
        self.votes
            .push((author, timeout.signature, timeout.high_qc.round));
        self.weight += committee.stake(&author);
        let mut threshold = committee.quorum_threshold();
        if timeout.seq == 0 {
            threshold = committee.large_threshold();
        }
        if self.weight >= threshold {
            self.weight = 0; // Ensures TC is only created once.
            return Ok(Some(TC {
                seq: timeout.seq,
                votes: self.votes.clone(),
            }));
        }
        Ok(None)
    }
pub fn append ( & mut self , timeout : Timeout , committee : & Committee , ) -> ConsensusResult < Option < TC > > { let author = timeout . author ; if self . used . contains ( & author ) { return Ok ( None ) ; } self . used . insert ( author ) ; // // Ensure it is the first time this authority votes. // ensure!( //     self.used.insert(author), //     ConsensusError::AuthorityReuseinTC(author) // ); // Add the timeout to the accumulator. self . votes . push ( ( author , timeout . signature , timeout . high_qc . round ) ) ; self . weight += committee . stake ( & author ) ; let mut threshold = committee . quorum_threshold ( ) ; if timeout . seq == 0 { threshold = committee . large_threshold ( ) ; } if self . weight >= threshold { self . weight = 0 ; // Ensures TC is only created once. return Ok ( Some ( TC { seq : timeout . seq , 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
timeout
Timeout
committee
&Committee
&mut self
timeout
Timeout
committee
&Committee