// Inspects the latest CUP height and the height of the latest finalized DKG
// summary block. If they are newer than what we have seen, triggers the
// loading of transcripts from corresponding summaries.
Inspects the latest CUP height and the height of the latest finalized DKG
summary block. If they are newer than what we have seen, triggers the
loading of transcripts from corresponding summaries.
Inspects the latest CUP height and the height of the latest finalized DKG summary block . If they are newer than what we have seen triggers the loading of transcripts from corresponding summaries .
fn load_transcripts_if_necessary(&mut self, pool_reader: &PoolReader<'_>) {
        let _timer = self
            .metrics
            .dkg_ops_duration
            .with_label_values(&["load_transcripts"])
            .start_timer();
        let cache = pool_reader.as_cache();
        // If the height of the latest CUP is higher than what we've seen before,
        // load its transcripts and update the latest seen height.
        let cup = cache.catch_up_package();
        let cup_height = Some(cup.height());
        if self.last_cup_height < cup_height {
            let summary = BlockPayload::from(cup.content.block.into_inner().payload).into_summary();
            self.load_transcripts_from_summary(Arc::new(summary.dkg));
            self.last_cup_height = cup_height;
        }
        // If the height of the latest finalized summary block is higher than what we
        // have seen before, we update the metrics, load the transcripts and update the
        // last seen height.
        let summary_block = cache.summary_block();
        if self.last_dkg_summary_height < Some(summary_block.height) {
            let summary = BlockPayload::from(summary_block.payload).into_summary();
            self.update_dkg_metrics(&summary.dkg);
            let dkg_summary = Arc::new(summary.dkg);
            // Note that the order of these two calls is critical. We remove DKG keys that
            // are no longer relevant by telling the CSP which transcripts are still
            // relevant. However, over time, we may load new transcripts that are relevant.
            // Since deletion blocks on the previous deletion, and we start loading after
            // deletion,  we know that the previous deletion must be completed, and
            // therefore newly loaded transcripts cannot be accidentally deleted.
            //
            // If we would switch the lines, we would start loading the new transcripts in
            // parallel with the previous removal and theoretically we could finish loading
            // the next transcript before the previous removal (which would consider the
            // next transcript key irrelevant and remove it).
            self.delete_inactive_keys(pool_reader);
            self.load_transcripts_from_summary(Arc::clone(&dkg_summary));
            self.last_dkg_summary_height = Some(summary_block.height);
        }
    }
fn load_transcripts_if_necessary ( & mut self , pool_reader : & PoolReader < ' _ > ) { let _timer = self . metrics . dkg_ops_duration . with_label_values ( & [ " " ] ) . start_timer ( ) ; let cache = pool_reader . as_cache ( ) ; // If the height of the latest CUP is higher than what we've seen before, // load its transcripts and update the latest seen height. let cup = cache . catch_up_package ( ) ; let cup_height = Some ( cup . height ( ) ) ; if self . last_cup_height < cup_height { let summary = BlockPayload :: from ( cup . content . block . into_inner ( ) . payload ) . into_summary ( ) ; self . load_transcripts_from_summary ( Arc :: new ( summary . dkg ) ) ; self . last_cup_height = cup_height ; } // If the height of the latest finalized summary block is higher than what we // have seen before, we update the metrics, load the transcripts and update the // last seen height. let summary_block = cache . summary_block ( ) ; if self . last_dkg_summary_height < Some ( summary_block . height ) { let summary = BlockPayload :: from ( summary_block . payload ) . into_summary ( ) ; self . update_dkg_metrics ( & summary . dkg ) ; let dkg_summary = Arc :: new ( summary . dkg ) ; // Note that the order of these two calls is critical. We remove DKG keys that // are no longer relevant by telling the CSP which transcripts are still // relevant. However, over time, we may load new transcripts that are relevant. // Since deletion blocks on the previous deletion, and we start loading after // deletion,  we know that the previous deletion must be completed, and // therefore newly loaded transcripts cannot be accidentally deleted. // // If we would switch the lines, we would start loading the new transcripts in // parallel with the previous removal and theoretically we could finish loading // the next transcript before the previous removal (which would consider the // next transcript key irrelevant and remove it). self . delete_inactive_keys ( pool_reader ) ; self . load_transcripts_from_summary ( Arc :: clone ( & dkg_summary ) ) ; self . last_dkg_summary_height = Some ( summary_block . height ) ; } }
Inspects the latest CUP height and the height of the latest finalized DKG
summary block.
Inspects the latest CUP height and the height of the latest finalized DKG summary block .
&mut self
pool_reader
&PoolReader<'_>