async fn handle_signed_qc(&mut self, signed_qc: SignedQC) -> ConsensusResult<()> {
        signed_qc.verify(&self.committee)?;
        self.update_fallback_high_qc(&signed_qc.qc);
        match signed_qc.random_coin {
            None => {
                // Already receive from the sender.
                let set = self.fallback_signed_qc_sender.entry(signed_qc.qc.view).or_insert(HashSet::new());
                if set.contains(&signed_qc.author) {
                    return Ok(());
                }

                if signed_qc.qc.fallback != 1 || signed_qc.qc.height != 2 || signed_qc.qc.view < self.view {
                    return Ok(());
                }

                set.insert(signed_qc.author);
                let weight = self.fallback_signed_qc_weight.entry(signed_qc.qc.view).or_insert(0);

                // Collected 2f+1 height-2 fallback QC, send randomness share
                *weight += self.committee.stake(&signed_qc.author);
                if *weight >= self.committee.quorum_threshold() {
                    *weight = 0; // Only send randomness share once
                    let leader_high_qc = match self.fallback_qcs.get(&self.name) {
                        Some(qc) => qc.clone(),
                        None => self.high_qc.clone()
                    };
                    // Multicast the randomness share with its height-2 QC
                    let randomness_share = RandomnessShare::new(signed_qc.qc.view, self.name, self.signature_service.clone(), Some(leader_high_qc.clone())).await;
                    let message = ConsensusMessage::RandomnessShare(randomness_share.clone());
                    Synchronizer::transmit(
                        message,
                        &self.name,
                        None,
                        &self.network_filter,
                        &self.committee,
                    )
                    .await?;
                    self.handle_randomness_share(randomness_share).await?;
                }
            },
            Some(ref random_coin) => {
                // This part won't be executed
                random_coin.verify(&self.committee, &self.pk_set)?;
                let view = random_coin.seq;
                if view < self.view {
                    return Ok(());
                }

                if self.leader_elector.get_fallback_leader(view).is_none() {
                    let leader_qcs = self.fallback_leader_qcs.entry(view).or_insert(Vec::new());
                    leader_qcs.push(signed_qc.clone());
                    return Ok(());
                }
                // Already receive from the sender.
                let set = self.fallback_leader_qc_sender.entry(view).or_insert(HashSet::new());
                if set.contains(&signed_qc.author) {
                    return Ok(());
                }

                set.insert(signed_qc.author);
                let weight = self.fallback_leader_qc_weight.entry(view).or_insert(0);

                // Collected 2f+1 QC of the elected leader, exit the fallback
                *weight += self.committee.stake(&signed_qc.author);
                if *weight >= self.committee.quorum_threshold() {
                    *weight = 0; 

                    self.exit_fallback(random_coin).await;
                }
            },
        }

        Ok(())
    }
// When receiving 2f+1 height-2 fallback QC, send randomness share
When receiving 2f+1 height-2 fallback QC, send randomness share
When receiving 2f + 1 height - 2 fallback QC send randomness share
async fn handle_signed_qc(&mut self, signed_qc: SignedQC) -> ConsensusResult<()> {
        signed_qc.verify(&self.committee)?;
        self.update_fallback_high_qc(&signed_qc.qc);
        match signed_qc.random_coin {
            None => {
                // Already receive from the sender.
                let set = self.fallback_signed_qc_sender.entry(signed_qc.qc.view).or_insert(HashSet::new());
                if set.contains(&signed_qc.author) {
                    return Ok(());
                }
                if signed_qc.qc.fallback != 1 || signed_qc.qc.height != 2 || signed_qc.qc.view < self.view {
                    return Ok(());
                }
                set.insert(signed_qc.author);
                let weight = self.fallback_signed_qc_weight.entry(signed_qc.qc.view).or_insert(0);
                // Collected 2f+1 height-2 fallback QC, send randomness share
                *weight += self.committee.stake(&signed_qc.author);
                if *weight >= self.committee.quorum_threshold() {
                    *weight = 0; // Only send randomness share once
                    let leader_high_qc = match self.fallback_qcs.get(&self.name) {
                        Some(qc) => qc.clone(),
                        None => self.high_qc.clone()
                    };
                    // Multicast the randomness share with its height-2 QC
                    let randomness_share = RandomnessShare::new(signed_qc.qc.view, self.name, self.signature_service.clone(), Some(leader_high_qc.clone())).await;
                    let message = ConsensusMessage::RandomnessShare(randomness_share.clone());
                    Synchronizer::transmit(
                        message,
                        &self.name,
                        None,
                        &self.network_filter,
                        &self.committee,
                    )
                    .await?;
                    self.handle_randomness_share(randomness_share).await?;
                }
            },
            Some(ref random_coin) => {
                // This part won't be executed
                random_coin.verify(&self.committee, &self.pk_set)?;
                let view = random_coin.seq;
                if view < self.view {
                    return Ok(());
                }
                if self.leader_elector.get_fallback_leader(view).is_none() {
                    let leader_qcs = self.fallback_leader_qcs.entry(view).or_insert(Vec::new());
                    leader_qcs.push(signed_qc.clone());
                    return Ok(());
                }
                // Already receive from the sender.
                let set = self.fallback_leader_qc_sender.entry(view).or_insert(HashSet::new());
                if set.contains(&signed_qc.author) {
                    return Ok(());
                }
                set.insert(signed_qc.author);
                let weight = self.fallback_leader_qc_weight.entry(view).or_insert(0);
                // Collected 2f+1 QC of the elected leader, exit the fallback
                *weight += self.committee.stake(&signed_qc.author);
                if *weight >= self.committee.quorum_threshold() {
                    *weight = 0; 
                    self.exit_fallback(random_coin).await;
                }
            },
        }
        Ok(())
    }
async fn handle_signed_qc ( & mut self , signed_qc : SignedQC ) -> ConsensusResult < ( ) > { signed_qc . verify ( & self . committee ) ? ; self . update_fallback_high_qc ( & signed_qc . qc ) ; match signed_qc . random_coin { None => { // Already receive from the sender. let set = self . fallback_signed_qc_sender . entry ( signed_qc . qc . view ) . or_insert ( HashSet :: new ( ) ) ; if set . contains ( & signed_qc . author ) { return Ok ( ( ) ) ; } if signed_qc . qc . fallback != 1 || signed_qc . qc . height != 2 || signed_qc . qc . view < self . view { return Ok ( ( ) ) ; } set . insert ( signed_qc . author ) ; let weight = self . fallback_signed_qc_weight . entry ( signed_qc . qc . view ) . or_insert ( 0 ) ; // Collected 2f+1 height-2 fallback QC, send randomness share * weight += self . committee . stake ( & signed_qc . author ) ; if * weight >= self . committee . quorum_threshold ( ) { * weight = 0 ; // Only send randomness share once let leader_high_qc = match self . fallback_qcs . get ( & self . name ) { Some ( qc ) => qc . clone ( ) , None => self . high_qc . clone ( ) } ; // Multicast the randomness share with its height-2 QC let randomness_share = RandomnessShare :: new ( signed_qc . qc . view , self . name , self . signature_service . clone ( ) , Some ( leader_high_qc . clone ( ) ) ) . await ; let message = ConsensusMessage :: RandomnessShare ( randomness_share . clone ( ) ) ; Synchronizer :: transmit ( message , & self . name , None , & self . network_filter , & self . committee , ) . await ? ; self . handle_randomness_share ( randomness_share ) . await ? ; } } , Some ( ref random_coin ) => { // This part won't be executed random_coin . verify ( & self . committee , & self . pk_set ) ? ; let view = random_coin . seq ; if view < self . view { return Ok ( ( ) ) ; } if self . leader_elector . get_fallback_leader ( view ) . is_none ( ) { let leader_qcs = self . fallback_leader_qcs . entry ( view ) . or_insert ( Vec :: new ( ) ) ; leader_qcs . push ( signed_qc . clone ( ) ) ; return Ok ( ( ) ) ; } // Already receive from the sender. let set = self . fallback_leader_qc_sender . entry ( view ) . or_insert ( HashSet :: new ( ) ) ; if set . contains ( & signed_qc . author ) { return Ok ( ( ) ) ; } set . insert ( signed_qc . author ) ; let weight = self . fallback_leader_qc_weight . entry ( view ) . or_insert ( 0 ) ; // Collected 2f+1 QC of the elected leader, exit the fallback * weight += self . committee . stake ( & signed_qc . author ) ; if * weight >= self . committee . quorum_threshold ( ) { * weight = 0 ; self . exit_fallback ( random_coin ) . await ; } } , } Ok ( ( ) ) }
When receiving 2f+1 height-2 fallback QC, send randomness share
When receiving 2f + 1 height - 2 fallback QC send randomness share
&mut self
signed_qc
SignedQC
&mut self
signed_qc
SignedQC