/// Checks, whether the transcript should have been loaded already by the
/// key manager or not, based on the height and it's list of transcript
/// loadings currently in progress.
Checks, whether the transcript should have been loaded already by the
key manager or not, based on the height and it's list of transcript
loadings currently in progress.
Checks whether the transcript should have been loaded already by the key manager or not based on the height and it ' s list of transcript loadings currently in progress .
pub fn is_transcript_loaded(&mut self, id: &NiDkgId) -> bool {
        // If the height of the last cup rsp. last summary is smaller than the id, we
        // know for sure, that we have not loaded this transcript
        let last_height = match std::cmp::max(self.last_cup_height, self.last_dkg_summary_height) {
            Some(height) => height,
            None => {
                info!(
                    every_n_seconds => 5,
                    self.logger,
                    "No transcripts have been loaded yet"
                );
                return false;
            }
        };
        if id.start_block_height > last_height && id.target_subnet == NiDkgTargetSubnet::Local {
            info!(
                every_n_seconds => 5,
                self.logger,
                "Transcript can't be loaded yet, last height too low: {:?} {:?}", last_height, id
            );
            return false;
        }
        // Get the receiver
        let rx = match self.pending_transcript_loads.get(id) {
            Some(rx) => &rx.1,
            None => {
                return true;
            }
        };
        // Try to get the loaded transcript
        match rx.try_recv() {
            // NOTE: we don't need to check the LoadTranscriptResult, since returning false here
            // means that the caller will next invoke dealing::create_dealing, so if the
            // key is no longer available, we will find out by then
            Ok(Ok(_)) => {
                // Remove the handle of the loaded transcript
                self.pending_transcript_loads.remove(id);
                true
            }
            Err(std::sync::mpsc::TryRecvError::Empty) => false,
            Err(std::sync::mpsc::TryRecvError::Disconnected) => {
                panic!("The dkg key manager thread panicked")
            }
            Ok(Err(err)) => panic!(
                "The DKG transcript with id={:?} couldn't be loaded: {:?}",
                id, err
            ),
        }
    }
pub fn is_transcript_loaded ( & mut self , id : & NiDkgId ) -> bool { // If the height of the last cup rsp. last summary is smaller than the id, we // know for sure, that we have not loaded this transcript let last_height = match std :: cmp :: max ( self . last_cup_height , self . last_dkg_summary_height ) { Some ( height ) => height , None => { info ! ( every_n_seconds 5 self logger " " ) ; return false ; } } ; if id . start_block_height > last_height && id . target_subnet == NiDkgTargetSubnet :: Local { info ! ( every_n_seconds 5 self logger " " last_height id ) ; return false ; } // Get the receiver let rx = match self . pending_transcript_loads . get ( id ) { Some ( rx ) => & rx . 1 , None => { return true ; } } ; // Try to get the loaded transcript match rx . try_recv ( ) { // NOTE: we don't need to check the LoadTranscriptResult, since returning false here // means that the caller will next invoke dealing::create_dealing, so if the // key is no longer available, we will find out by then Ok ( Ok ( _ ) ) => { // Remove the handle of the loaded transcript self . pending_transcript_loads . remove ( id ) ; true } Err ( std :: sync :: mpsc :: TryRecvError :: Empty ) => false , Err ( std :: sync :: mpsc :: TryRecvError :: Disconnected ) => { panic ! ( " " ) } Ok ( Err ( err ) ) => panic ! ( " " id err ) , } }
Checks, whether the transcript should have been loaded already by the
key manager or not, based on the height and it's list of transcript
loadings currently in progress.
Checks whether the transcript should have been loaded already by the key manager or not based on the height and it ' s list of transcript loadings currently in progress .
&mut self
id
&NiDkgId