fn sign(
        &self,
        consensus_cache: &dyn ConsensusPoolCache,
        certification_pool: &dyn CertificationPool,
        state_hashes: &[(Height, CryptoHashOfPartialState)],
    ) -> Vec<CertificationMessage> {
        state_hashes
            .iter()
            .cloned()
            // Filter out all heights, where the current replica does not belong to the committee
            // and, hence, should not sign.
            .filter(|(height, _)| {
                self.membership
                    .node_belongs_to_threshold_committee(
                        self.replica_config.node_id,
                        *height,
                        Certification::committee(),
                    )
                    .unwrap_or_else(|err| {
                        debug!(
                            self.log,
                            "Couldn't check committee membership while signing: {:?}", err
                        );
                        false
                    })
            })
            // Filter out all heights if we have a share signed by us already (this is a linear scan
            // through all shares of the same height, but is bound by the number of replicas).
            .filter(|(height, _)| {
                certification_pool
                    .shares_at_height(*height)
                    .all(|share| share.signed.signature.signer != self.replica_config.node_id)
            })
            .filter_map(|(height, hash)| {
                let content = CertificationContent::new(hash);
                let dkg_id =
                    utils::active_high_threshold_transcript(consensus_cache, height)?.dkg_id;
                match self
                    .crypto
                    .sign(&content, self.replica_config.node_id, dkg_id)
                {
                    Ok(signature) => Some(CertificationShare {
                        height,
                        signed: Signed { content, signature },
                    }),
                    Err(err) => {
                        error!(self.log, "Couldn't create a signature: {:?}", err);
                        None
                    }
                }
            })
            .map(CertificationMessage::CertificationShare)
            .collect()
    }
// Gets height/hash pairs and creates certification shares for them.
Gets height/hash pairs and creates certification shares for them.
Gets height / hash pairs and creates certification shares for them .
fn sign(
        &self,
        consensus_cache: &dyn ConsensusPoolCache,
        certification_pool: &dyn CertificationPool,
        state_hashes: &[(Height, CryptoHashOfPartialState)],
    ) -> Vec<CertificationMessage> {
        state_hashes
            .iter()
            .cloned()
            // Filter out all heights, where the current replica does not belong to the committee
            // and, hence, should not sign.
            .filter(|(height, _)| {
                self.membership
                    .node_belongs_to_threshold_committee(
                        self.replica_config.node_id,
                        *height,
                        Certification::committee(),
                    )
                    .unwrap_or_else(|err| {
                        debug!(
                            self.log,
                            "Couldn't check committee membership while signing: {:?}", err
                        );
                        false
                    })
            })
            // Filter out all heights if we have a share signed by us already (this is a linear scan
            // through all shares of the same height, but is bound by the number of replicas).
            .filter(|(height, _)| {
                certification_pool
                    .shares_at_height(*height)
                    .all(|share| share.signed.signature.signer != self.replica_config.node_id)
            })
            .filter_map(|(height, hash)| {
                let content = CertificationContent::new(hash);
                let dkg_id =
                    utils::active_high_threshold_transcript(consensus_cache, height)?.dkg_id;
                match self
                    .crypto
                    .sign(&content, self.replica_config.node_id, dkg_id)
                {
                    Ok(signature) => Some(CertificationShare {
                        height,
                        signed: Signed { content, signature },
                    }),
                    Err(err) => {
                        error!(self.log, "Couldn't create a signature: {:?}", err);
                        None
                    }
                }
            })
            .map(CertificationMessage::CertificationShare)
            .collect()
    }
fn sign ( & self , consensus_cache : & dyn ConsensusPoolCache , certification_pool : & dyn CertificationPool , state_hashes : & [ ( Height , CryptoHashOfPartialState ) ] , ) -> Vec < CertificationMessage > { state_hashes . iter ( ) . cloned ( ) // Filter out all heights, where the current replica does not belong to the committee // and, hence, should not sign. . filter ( | ( height , _ ) | { self . membership . node_belongs_to_threshold_committee ( self . replica_config . node_id , * height , Certification :: committee ( ) , ) . unwrap_or_else ( | err | { debug ! ( self log " " err ) ; false } ) } ) // Filter out all heights if we have a share signed by us already (this is a linear scan // through all shares of the same height, but is bound by the number of replicas). . filter ( | ( height , _ ) | { certification_pool . shares_at_height ( * height ) . all ( | share | share . signed . signature . signer != self . replica_config . node_id ) } ) . filter_map ( | ( height , hash ) | { let content = CertificationContent :: new ( hash ) ; let dkg_id = utils :: active_high_threshold_transcript ( consensus_cache , height ) ? . dkg_id ; match self . crypto . sign ( & content , self . replica_config . node_id , dkg_id ) { Ok ( signature ) => Some ( CertificationShare { height , signed : Signed { content , signature } , } ) , Err ( err ) => { error ! ( self log " " err ) ; None } } } ) . map ( CertificationMessage :: CertificationShare ) . collect ( ) }
Gets height/hash pairs and creates certification shares for them.
Gets height / hash pairs and creates certification shares for them .
&self
consensus_cache
&dyn ConsensusPoolCache
certification_pool
&dyn CertificationPool
state_hashes
&[(Height, CryptoHashOfPartialState)]
&self
consensus_cache
&dyn ConsensusPoolCache
certification_pool
&dyn CertificationPool
state_hashes
&[(Height, CryptoHashOfPartialState)]