fn enforce_transcript_loading(&mut self, pool_reader: &PoolReader<'_>) {
        let _timer = self
            .metrics
            .dkg_ops_duration
            .with_label_values(&["enforce_transcripts"])
            .start_timer();
        let next_random_beacon_height = pool_reader.get_random_beacon_height().increment();
        // If there are no expired transcripts, which we expected in the most of rounds,
        // we're done.
        if self
            .pending_transcript_loads
            .iter()
            .all(|(_, (deadline, _))| *deadline > next_random_beacon_height)
        {
            return;
        }
        let (expired, pending): (Vec<_>, _) = self
            .pending_transcript_loads
            .drain()
            .partition(|(_, (deadline, _))| next_random_beacon_height >= *deadline);
        let number_of_transcripts = expired.len();
        info!(
            self.logger,
            "Waiting on {} transcripts to be loaded", number_of_transcripts
        );
        for (id, (_, handle)) in expired {
            match handle.recv() {
                Err(err) => panic!(
                    "Couldn't finish transcript loading with id={:?}: {:?}",
                    id, err
                ),
                Ok(Err(err)) => panic!(
                    "The DKG transcript with id={:?} couldn't be loaded: {:?}",
                    id, err
                ),
                _ => (),
            }
        }
        info!(
            self.logger,
            "Finished waiting on {} transcripts to be loaded", number_of_transcripts,
        );
        // Put the pending loads back.
        self.pending_transcript_loads = pending.into_iter().collect();
    }
// Ensures that the pending transcripts are loaded BEFORE they are needed. For
// that we take the next expected random beacon height and check for every
// pending transcript load if we hit its deadline. If yes, we join on the
// thread handle by enforcing its execution if it didn't happen yet or by
// closing the thread otherwise.
Ensures that the pending transcripts are loaded BEFORE they are needed. For
that we take the next expected random beacon height and check for every
pending transcript load if we hit its deadline. If yes, we join on the
thread handle by enforcing its execution if it didn't happen yet or by
closing the thread otherwise.
Ensures that the pending transcripts are loaded BEFORE they are needed . For that we take the next expected random beacon height and check for every pending transcript load if we hit its deadline . If yes we join on the thread handle by enforcing its execution if it didn ' t happen yet or by closing the thread otherwise .
fn enforce_transcript_loading(&mut self, pool_reader: &PoolReader<'_>) {
        let _timer = self
            .metrics
            .dkg_ops_duration
            .with_label_values(&["enforce_transcripts"])
            .start_timer();
        let next_random_beacon_height = pool_reader.get_random_beacon_height().increment();
        // If there are no expired transcripts, which we expected in the most of rounds,
        // we're done.
        if self
            .pending_transcript_loads
            .iter()
            .all(|(_, (deadline, _))| *deadline > next_random_beacon_height)
        {
            return;
        }
        let (expired, pending): (Vec<_>, _) = self
            .pending_transcript_loads
            .drain()
            .partition(|(_, (deadline, _))| next_random_beacon_height >= *deadline);
        let number_of_transcripts = expired.len();
        info!(
            self.logger,
            "Waiting on {} transcripts to be loaded", number_of_transcripts
        );
        for (id, (_, handle)) in expired {
            match handle.recv() {
                Err(err) => panic!(
                    "Couldn't finish transcript loading with id={:?}: {:?}",
                    id, err
                ),
                Ok(Err(err)) => panic!(
                    "The DKG transcript with id={:?} couldn't be loaded: {:?}",
                    id, err
                ),
                _ => (),
            }
        }
        info!(
            self.logger,
            "Finished waiting on {} transcripts to be loaded", number_of_transcripts,
        );
        // Put the pending loads back.
        self.pending_transcript_loads = pending.into_iter().collect();
    }
fn enforce_transcript_loading ( & mut self , pool_reader : & PoolReader < ' _ > ) { let _timer = self . metrics . dkg_ops_duration . with_label_values ( & [ " " ] ) . start_timer ( ) ; let next_random_beacon_height = pool_reader . get_random_beacon_height ( ) . increment ( ) ; // If there are no expired transcripts, which we expected in the most of rounds, // we're done. if self . pending_transcript_loads . iter ( ) . all ( | ( _ , ( deadline , _ ) ) | * deadline > next_random_beacon_height ) { return ; } let ( expired , pending ) : ( Vec < _ > , _ ) = self . pending_transcript_loads . drain ( ) . partition ( | ( _ , ( deadline , _ ) ) | next_random_beacon_height >= * deadline ) ; let number_of_transcripts = expired . len ( ) ; info ! ( self logger " " number_of_transcripts ) ; for ( id , ( _ , handle ) ) in expired { match handle . recv ( ) { Err ( err ) => panic ! ( " " id err ) , Ok ( Err ( err ) ) => panic ! ( " " id err ) , _ => ( ) , } } info ! ( self logger " " number_of_transcripts ) ; // Put the pending loads back. self . pending_transcript_loads = pending . into_iter ( ) . collect ( ) ; }
Ensures that the pending transcripts are loaded BEFORE they are needed.
Ensures that the pending transcripts are loaded BEFORE they are needed .
&mut self
pool_reader
&PoolReader<'_>
&mut self
pool_reader
&PoolReader<'_>