// Ask the CSP to drop DKG key material related to transcripts that are no
// longer relevant
Ask the CSP to drop DKG key material related to transcripts that are no
longer relevant
Ask the CSP to drop DKG key material related to transcripts that are no longer relevant
fn delete_inactive_keys(&mut self, pool_reader: &PoolReader<'_>) {
        if let Some(handle) = self.pending_key_removal.take() {
            // To make sure we delete all keys sequentially, we check if another key removal
            // is ongoing and if yes, we block until this thread is done. This
            // operation will only actually block, if the previous key removal
            // didn't finish yet. This should never happen in a normal operation
            // mode as we trigger the removal at the start of each DKG interval and
            // such an interval is expected to take significantly longer than the
            // key removal.
            handle
                .join()
                .unwrap_or_else(|err| panic!("Couldn't finish the DKG key removal: {:?}", err));
        }
        // Create list of transcripts that we need to retain, which is all DKG
        // transcripts in the latest CUP and in all subsequent finalized summary blocks.
        let mut transcripts_to_retain: HashSet<NiDkgTranscript> = HashSet::new();
        let mut dkg_summary = Some(
            BlockPayload::from(
                pool_reader
                    .cache
                    .catch_up_package()
                    .content
                    .block
                    .into_inner()
                    .payload,
            )
            .into_summary(),
        );
        while let Some(summary) = dkg_summary {
            let next_summary_height = summary.dkg.get_next_start_height();
            for transcript in summary.dkg.into_transcripts() {
                transcripts_to_retain.insert(transcript);
            }
            dkg_summary = pool_reader
                .get_finalized_block(next_summary_height)
                .map(|b| BlockPayload::from(b.payload).into_summary());
        }
        let crypto = self.crypto.clone();
        let logger = self.logger.clone();
        let handle = std::thread::spawn(move || {
            NiDkgAlgorithm::retain_only_active_keys(&*crypto, transcripts_to_retain)
                .unwrap_or_else(|err| error!(logger, "Could not delete DKG keys: {:?}", err));
        });
        self.pending_key_removal = Some(handle);
    }
fn delete_inactive_keys ( & mut self , pool_reader : & PoolReader < ' _ > ) { if let Some ( handle ) = self . pending_key_removal . take ( ) { // To make sure we delete all keys sequentially, we check if another key removal // is ongoing and if yes, we block until this thread is done. This // operation will only actually block, if the previous key removal // didn't finish yet. This should never happen in a normal operation // mode as we trigger the removal at the start of each DKG interval and // such an interval is expected to take significantly longer than the // key removal. handle . join ( ) . unwrap_or_else ( | err | panic ! ( " " err ) ) ; } // Create list of transcripts that we need to retain, which is all DKG // transcripts in the latest CUP and in all subsequent finalized summary blocks. let mut transcripts_to_retain : HashSet < NiDkgTranscript > = HashSet :: new ( ) ; let mut dkg_summary = Some ( BlockPayload :: from ( pool_reader . cache . catch_up_package ( ) . content . block . into_inner ( ) . payload , ) . into_summary ( ) , ) ; while let Some ( summary ) = dkg_summary { let next_summary_height = summary . dkg . get_next_start_height ( ) ; for transcript in summary . dkg . into_transcripts ( ) { transcripts_to_retain . insert ( transcript ) ; } dkg_summary = pool_reader . get_finalized_block ( next_summary_height ) . map ( | b | BlockPayload :: from ( b . payload ) . into_summary ( ) ) ; } let crypto = self . crypto . clone ( ) ; let logger = self . logger . clone ( ) ; let handle = std :: thread :: spawn ( move | | { NiDkgAlgorithm :: retain_only_active_keys ( & * crypto , transcripts_to_retain ) . unwrap_or_else ( | err | error ! ( logger " " err ) ) ; } ) ; self . pending_key_removal = Some ( handle ) ; }
Ask the CSP to drop DKG key material related to transcripts that are no
longer relevant
Ask the CSP to drop DKG key material related to transcripts that are no longer relevant
&mut self
pool_reader
&PoolReader<'_>