/// Run a single step of consensus, dkg and certification by repeatedly
/// calling on_state_change and apply the changes until no more changes
/// occur.
///
/// Return a list of output messages produced in the process.
Run a single step of consensus, dkg and certification by repeatedly
calling on_state_change and apply the changes until no more changes
occur.

Return a list of output messages produced in the process.
Run a single step of consensus dkg and certification by repeatedly calling on_state_change and apply the changes until no more changes occur . Return a list of output messages produced in the process .
pub fn step(&self, time_source: &dyn TimeSource) -> Vec<InputMessage> {
        let mut to_deliver = Vec::new();
        loop {
            let changeset = self.consensus.on_state_change(
                &*self.consensus_pool.read().unwrap(),
                &*self.ingress_pool.borrow(),
            );
            if changeset.is_empty() {
                break;
            }
            for change_action in &changeset {
                match change_action {
                    // MoveToValidated are what we have received and verified.
                    // But we don't deliver them to peers.
                    ChangeAction::MoveToValidated(to_move) => {
                        debug_print_msg(&self.logger, "Receive", to_move);
                    }
                    // AddToValidated are what we have produced.
                    // We will deliver them to peers.
                    ChangeAction::AddToValidated(to_add) => {
                        debug_print_msg(&self.logger, "Deliver", to_add);
                        to_deliver.push(InputMessage::Consensus(to_add.clone()));
                    }
                    _ => (),
                }
            }
            self.consensus_pool
                .write()
                .unwrap()
                .apply_changes(time_source, changeset);
        }
        loop {
            let changeset = self.dkg.on_state_change(&*self.dkg_pool.read().unwrap());
            if changeset.is_empty() {
                break;
            }
            {
                for change_action in &changeset {
                    if let DkgChangeAction::AddToValidated(to_add) = change_action {
                        debug!(self.logger, "Deliver {:?}", to_add);
                        to_deliver.push(InputMessage::Dkg(to_add.clone()));
                    }
                }
                let dkg_pool = &mut self.dkg_pool.write().unwrap();
                dkg_pool.apply_changes(changeset);
            }
        }
        loop {
            let changeset = self.certifier.on_state_change(
                self.consensus_pool.read().unwrap().as_cache(),
                self.certification_pool.clone(),
            );
            if changeset.is_empty() {
                break;
            }
            {
                for change_action in &changeset {
                    if let certification::ChangeAction::AddToValidated(msg) = change_action {
                        debug!(self.logger, "Certification Message Deliver {:?}", msg);
                        to_deliver.push(InputMessage::Certification(msg.clone()));
                    }
                    if let certification::ChangeAction::MoveToValidated(msg) = change_action {
                        debug!(self.logger, "Certification Message Validated {:?}", msg);
                    }
                }
                let mut certification_pool = self.certification_pool.write().unwrap();
                certification_pool.apply_changes(changeset);
            }
        }
        to_deliver
    }
pub fn step ( & self , time_source : & dyn TimeSource ) -> Vec < InputMessage > { let mut to_deliver = Vec :: new ( ) ; loop { let changeset = self . consensus . on_state_change ( & * self . consensus_pool . read ( ) . unwrap ( ) , & * self . ingress_pool . borrow ( ) , ) ; if changeset . is_empty ( ) { break ; } for change_action in & changeset { match change_action { // MoveToValidated are what we have received and verified. // But we don't deliver them to peers. ChangeAction :: MoveToValidated ( to_move ) => { debug_print_msg ( & self . logger , " " , to_move ) ; } // AddToValidated are what we have produced. // We will deliver them to peers. ChangeAction :: AddToValidated ( to_add ) => { debug_print_msg ( & self . logger , " " , to_add ) ; to_deliver . push ( InputMessage :: Consensus ( to_add . clone ( ) ) ) ; } _ => ( ) , } } self . consensus_pool . write ( ) . unwrap ( ) . apply_changes ( time_source , changeset ) ; } loop { let changeset = self . dkg . on_state_change ( & * self . dkg_pool . read ( ) . unwrap ( ) ) ; if changeset . is_empty ( ) { break ; } { for change_action in & changeset { if let DkgChangeAction :: AddToValidated ( to_add ) = change_action { debug ! ( self logger " " to_add ) ; to_deliver . push ( InputMessage :: Dkg ( to_add . clone ( ) ) ) ; } } let dkg_pool = & mut self . dkg_pool . write ( ) . unwrap ( ) ; dkg_pool . apply_changes ( changeset ) ; } } loop { let changeset = self . certifier . on_state_change ( self . consensus_pool . read ( ) . unwrap ( ) . as_cache ( ) , self . certification_pool . clone ( ) , ) ; if changeset . is_empty ( ) { break ; } { for change_action in & changeset { if let certification :: ChangeAction :: AddToValidated ( msg ) = change_action { debug ! ( self logger " " msg ) ; to_deliver . push ( InputMessage :: Certification ( msg . clone ( ) ) ) ; } if let certification :: ChangeAction :: MoveToValidated ( msg ) = change_action { debug ! ( self logger " " msg ) ; } } let mut certification_pool = self . certification_pool . write ( ) . unwrap ( ) ; certification_pool . apply_changes ( changeset ) ; } } to_deliver }
Run a single step of consensus, dkg and certification by repeatedly
calling on_state_change and apply the changes until no more changes
occur.
Run a single step of consensus dkg and certification by repeatedly calling on_state_change and apply the changes until no more changes occur .
&self
time_source
&dyn TimeSource