// Create a dealing for the given DKG config if necessary. That is, if this
// replica is a dealer for the config and hasn't yet created a dealing, it will
// return a change action to add a dealing.
Create a dealing for the given DKG config if necessary. That is, if this
replica is a dealer for the config and hasn't yet created a dealing, it will
return a change action to add a dealing.
Create a dealing for the given DKG config if necessary . That is if this replica is a dealer for the config and hasn ' t yet created a dealing it will return a change action to add a dealing .
fn create_dealing(&self, dkg_pool: &dyn DkgPool, config: &NiDkgConfig) -> Option<ChangeAction> {
        // Do not produce any dealings if the dealers list does not contain the id of
        // the current replica, or the current replica has already produced dealings.
        if !config.dealers().get().contains(&self.node_id)
            || contains_dkg_messages(dkg_pool, config, self.node_id)
        {
            return None;
        }
        // If the transcript is being loaded at the moment, we return early.
        // The transcript will be available at a later point in time.
        if let Some(transcript) = config.resharing_transcript() {
            if !self
                .dkg_key_manager
                .lock()
                .unwrap()
                .is_transcript_loaded(&transcript.dkg_id)
            {
                return None;
            }
        }
        let content =
            match ic_interfaces::crypto::NiDkgAlgorithm::create_dealing(&*self.crypto, config) {
                Ok(dealing) => DealingContent::new(dealing, config.dkg_id()),
                Err(err) => {
                    match config.dkg_id().target_subnet {
                        NiDkgTargetSubnet::Local => error!(
                            self.logger,
                            "Couldn't create a DKG dealing at height {:?}: {:?}",
                            config.dkg_id().start_block_height,
                            err
                        ),
                        // NOTE: In rare cases, we might hit this case.
                        NiDkgTargetSubnet::Remote(_) => info!(
                            self.logger,
                            "Waiting for Remote DKG dealing at height {:?}: {:?}",
                            config.dkg_id().start_block_height,
                            err
                        ),
                    };
                    return None;
                }
            };
        match self
            .crypto
            .sign(&content, self.node_id, config.registry_version())
        {
            Ok(signature) => Some(ChangeAction::AddToValidated(Signed { content, signature })),
            Err(err) => {
                error!(self.logger, "Couldn't sign a DKG dealing: {:?}", err);
                None
            }
        }
    }
fn create_dealing ( & self , dkg_pool : & dyn DkgPool , config : & NiDkgConfig ) -> Option < ChangeAction > { // Do not produce any dealings if the dealers list does not contain the id of // the current replica, or the current replica has already produced dealings. if ! config . dealers ( ) . get ( ) . contains ( & self . node_id ) || contains_dkg_messages ( dkg_pool , config , self . node_id ) { return None ; } // If the transcript is being loaded at the moment, we return early. // The transcript will be available at a later point in time. if let Some ( transcript ) = config . resharing_transcript ( ) { if ! self . dkg_key_manager . lock ( ) . unwrap ( ) . is_transcript_loaded ( & transcript . dkg_id ) { return None ; } } let content = match ic_interfaces :: crypto :: NiDkgAlgorithm :: create_dealing ( & * self . crypto , config ) { Ok ( dealing ) => DealingContent :: new ( dealing , config . dkg_id ( ) ) , Err ( err ) => { match config . dkg_id ( ) . target_subnet { NiDkgTargetSubnet :: Local => error ! ( self logger " " config dkg_id ( ) start_block_height err ) , // NOTE: In rare cases, we might hit this case. NiDkgTargetSubnet :: Remote ( _ ) => info ! ( self logger " " config dkg_id ( ) start_block_height err ) , } ; return None ; } } ; match self . crypto . sign ( & content , self . node_id , config . registry_version ( ) ) { Ok ( signature ) => Some ( ChangeAction :: AddToValidated ( Signed { content , signature } ) ) , Err ( err ) => { error ! ( self logger " " err ) ; None } } }
Create a dealing for the given DKG config if necessary.
Create a dealing for the given DKG config if necessary .
&self
dkg_pool
&dyn DkgPool
config
&NiDkgConfig