fn load_transcripts_from_summary(&mut self, summary: Arc<Summary>) {
        let transcripts_to_load: Vec<_> = {
            let current_interval_start = summary.height;
            let next_interval_start = summary.get_next_start_height();
            // For current transcripts we take the current summary height as a deadline.
            let current_transcripts_with_load_deadlines = summary
                .current_transcripts()
                .iter()
                .filter(|(_, t)| !self.pending_transcript_loads.contains_key(&t.dkg_id))
                .map(|(_, t)| (current_interval_start, t.dkg_id));
            // For next transcripts, we take the start of the next interval as a deadline.
            let next_transcripts_with_load_deadlines = summary
                .next_transcripts()
                .iter()
                .filter(|(_, t)| !self.pending_transcript_loads.contains_key(&t.dkg_id))
                .map(|(_, t)| (next_interval_start, t.dkg_id));

            current_transcripts_with_load_deadlines
                .chain(next_transcripts_with_load_deadlines)
                .collect()
        };

        for (deadline, dkg_id) in transcripts_to_load.into_iter() {
            info!(
                self.logger,
                "Start asynchronously loading the DKG transcript with id={:?}", dkg_id,
            );
            let crypto = self.crypto.clone();
            let logger = self.logger.clone();
            let summary = summary.clone();
            let (tx, rx) = sync_channel(0);
            std::thread::spawn(move || {
                let transcript = summary
                    .current_transcripts()
                    .iter()
                    .chain(summary.next_transcripts().iter())
                    .find(|(_, t)| t.dkg_id == dkg_id)
                    .expect("No transcript was found")
                    .1;

                let result = NiDkgAlgorithm::load_transcript(&*crypto, transcript);
                match &result {
                    Ok(_) => info!(logger, "Finished loading transcript with id={:?}", dkg_id),
                    Err(err) => warn!(
                        logger,
                        "The DKG transcript with id={:?} couldn't be loaded: {:?}", dkg_id, err
                    ),
                }
                tx.send(result)
            });
            self.pending_transcript_loads.insert(dkg_id, (deadline, rx));
        }
    }
// Gets all available transcripts from a summary (current + next ones) and
// spawns threads for every transcript load if it's not among transcripts
// being loaded already. Note this functionality relies on the assumption,
// that CSP does not re-load transcripts, which were succeffully loaded
// before.
Gets all available transcripts from a summary (current + next ones) and
spawns threads for every transcript load if it's not among transcripts
being loaded already. Note this functionality relies on the assumption,
that CSP does not re-load transcripts, which were succeffully loaded
before.
Gets all available transcripts from a summary ( current + next ones ) and spawns threads for every transcript load if it ' s not among transcripts being loaded already . Note this functionality relies on the assumption that CSP does not re - load transcripts which were succeffully loaded before .
fn load_transcripts_from_summary(&mut self, summary: Arc<Summary>) {
        let transcripts_to_load: Vec<_> = {
            let current_interval_start = summary.height;
            let next_interval_start = summary.get_next_start_height();
            // For current transcripts we take the current summary height as a deadline.
            let current_transcripts_with_load_deadlines = summary
                .current_transcripts()
                .iter()
                .filter(|(_, t)| !self.pending_transcript_loads.contains_key(&t.dkg_id))
                .map(|(_, t)| (current_interval_start, t.dkg_id));
            // For next transcripts, we take the start of the next interval as a deadline.
            let next_transcripts_with_load_deadlines = summary
                .next_transcripts()
                .iter()
                .filter(|(_, t)| !self.pending_transcript_loads.contains_key(&t.dkg_id))
                .map(|(_, t)| (next_interval_start, t.dkg_id));
            current_transcripts_with_load_deadlines
                .chain(next_transcripts_with_load_deadlines)
                .collect()
        };
        for (deadline, dkg_id) in transcripts_to_load.into_iter() {
            info!(
                self.logger,
                "Start asynchronously loading the DKG transcript with id={:?}", dkg_id,
            );
            let crypto = self.crypto.clone();
            let logger = self.logger.clone();
            let summary = summary.clone();
            let (tx, rx) = sync_channel(0);
            std::thread::spawn(move || {
                let transcript = summary
                    .current_transcripts()
                    .iter()
                    .chain(summary.next_transcripts().iter())
                    .find(|(_, t)| t.dkg_id == dkg_id)
                    .expect("No transcript was found")
                    .1;
                let result = NiDkgAlgorithm::load_transcript(&*crypto, transcript);
                match &result {
                    Ok(_) => info!(logger, "Finished loading transcript with id={:?}", dkg_id),
                    Err(err) => warn!(
                        logger,
                        "The DKG transcript with id={:?} couldn't be loaded: {:?}", dkg_id, err
                    ),
                }
                tx.send(result)
            });
            self.pending_transcript_loads.insert(dkg_id, (deadline, rx));
        }
    }
fn load_transcripts_from_summary ( & mut self , summary : Arc < Summary > ) { let transcripts_to_load : Vec < _ > = { let current_interval_start = summary . height ; let next_interval_start = summary . get_next_start_height ( ) ; // For current transcripts we take the current summary height as a deadline. let current_transcripts_with_load_deadlines = summary . current_transcripts ( ) . iter ( ) . filter ( | ( _ , t ) | ! self . pending_transcript_loads . contains_key ( & t . dkg_id ) ) . map ( | ( _ , t ) | ( current_interval_start , t . dkg_id ) ) ; // For next transcripts, we take the start of the next interval as a deadline. let next_transcripts_with_load_deadlines = summary . next_transcripts ( ) . iter ( ) . filter ( | ( _ , t ) | ! self . pending_transcript_loads . contains_key ( & t . dkg_id ) ) . map ( | ( _ , t ) | ( next_interval_start , t . dkg_id ) ) ; current_transcripts_with_load_deadlines . chain ( next_transcripts_with_load_deadlines ) . collect ( ) } ; for ( deadline , dkg_id ) in transcripts_to_load . into_iter ( ) { info ! ( self logger " " dkg_id ) ; let crypto = self . crypto . clone ( ) ; let logger = self . logger . clone ( ) ; let summary = summary . clone ( ) ; let ( tx , rx ) = sync_channel ( 0 ) ; std :: thread :: spawn ( move | | { let transcript = summary . current_transcripts ( ) . iter ( ) . chain ( summary . next_transcripts ( ) . iter ( ) ) . find ( | ( _ , t ) | t . dkg_id == dkg_id ) . expect ( " " ) . 1 ; let result = NiDkgAlgorithm :: load_transcript ( & * crypto , transcript ) ; match & result { Ok ( _ ) => info ! ( logger " " dkg_id ) , Err ( err ) => warn ! ( logger " " dkg_id err ) , } tx . send ( result ) } ) ; self . pending_transcript_loads . insert ( dkg_id , ( deadline , rx ) ) ; } }
Gets all available transcripts from a summary (current + next ones) and
spawns threads for every transcript load if it's not among transcripts
being loaded already.
Gets all available transcripts from a summary ( current + next ones ) and spawns threads for every transcript load if it ' s not among transcripts being loaded already .
&mut self
summary
Arc<Summary>
&mut self
summary
Arc<Summary>