/// The method processes changes in the DKG pool.
The method processes changes in the DKG pool.
The method processes changes in the DKG pool .
fn process_changes(
        &self,
        _time_source: &dyn TimeSource,
        artifacts: Vec<UnvalidatedArtifact<dkg::Message>>,
    ) -> (Vec<Advert<DkgArtifact>>, ProcessingResult) {
        {
            let mut dkg_pool = self.dkg_pool.write().unwrap();
            for artifact in artifacts {
                dkg_pool.insert(artifact)
            }
        }
        let mut adverts = Vec::new();
        let change_set = {
            let dkg_pool = self.dkg_pool.read().unwrap();
            let change_set = self.client.on_state_change(&*dkg_pool);
            for change_action in change_set.iter() {
                match change_action {
                    DkgChangeAction::AddToValidated(to_add) => {
                        adverts.push(DkgArtifact::message_to_advert(to_add))
                    }
                    DkgChangeAction::MoveToValidated(message) => {
                        adverts.push(DkgArtifact::message_to_advert(message))
                    }
                    DkgChangeAction::HandleInvalid(msg, reason) => {
                        self.invalidated_artifacts.inc();
                        warn!(self.log, "Invalid DKG message ({:?}): {:?}", reason, msg);
                    }
                    _ => (),
                }
            }
            change_set
        };
        let changed = if !change_set.is_empty() {
            ProcessingResult::StateChanged
        } else {
            ProcessingResult::StateUnchanged
        };
        self.dkg_pool.write().unwrap().apply_changes(change_set);
        (adverts, changed)
    }
fn process_changes ( & self , _time_source : & dyn TimeSource , artifacts : Vec < UnvalidatedArtifact < dkg :: Message > > , ) -> ( Vec < Advert < DkgArtifact > > , ProcessingResult ) { { let mut dkg_pool = self . dkg_pool . write ( ) . unwrap ( ) ; for artifact in artifacts { dkg_pool . insert ( artifact ) } } let mut adverts = Vec :: new ( ) ; let change_set = { let dkg_pool = self . dkg_pool . read ( ) . unwrap ( ) ; let change_set = self . client . on_state_change ( & * dkg_pool ) ; for change_action in change_set . iter ( ) { match change_action { DkgChangeAction :: AddToValidated ( to_add ) => { adverts . push ( DkgArtifact :: message_to_advert ( to_add ) ) } DkgChangeAction :: MoveToValidated ( message ) => { adverts . push ( DkgArtifact :: message_to_advert ( message ) ) } DkgChangeAction :: HandleInvalid ( msg , reason ) => { self . invalidated_artifacts . inc ( ) ; warn ! ( self log " " reason msg ) ; } _ => ( ) , } } change_set } ; let changed = if ! change_set . is_empty ( ) { ProcessingResult :: StateChanged } else { ProcessingResult :: StateUnchanged } ; self . dkg_pool . write ( ) . unwrap ( ) . apply_changes ( change_set ) ; ( adverts , changed ) }
The method processes changes in the DKG pool.
The method processes changes in the DKG pool .
&self
_time_source
&dyn TimeSource
artifacts
Vec<UnvalidatedArtifact<dkg::Message>>