/// Updates the current Honey Badger epoch.
Updates the current Honey Badger epoch.
Updates the current Honey Badger epoch .
fn update_epoch(&mut self, step: &CpStep<D>) -> CpStep<Self> {
        if step.output.is_empty() {
            return Step::<D>::default();
        }
        // If this node removes itself after this epoch, it should send an `EpochStarted` with the
        // next epoch and then go offline.
        let mut send_last_epoch_started = false;
        // Look up `DynamicHoneyBadger` epoch updates and collect any added peers.
        for batch in &step.output {
            if let Some(next_participants) = batch.participant_change() {
                // Insert candidates.
                for id in &next_participants {
                    if id != self.our_id() {
                        self.peer_epochs.entry(id.clone()).or_default();
                        if let Some(&last) = self.last_epochs.get(id) {
                            if last < batch.output_epoch() {
                                self.last_epochs.remove(id);
                            }
                        }
                    }
                }
                debug!(
                    "Participants after the last change: {:?}",
                    self.participants_after_change
                );
                debug!("Next participants: {:?}", next_participants);
                // Remove obsolete participants.
                for id in self
                    .participants_after_change
                    .clone()
                    .difference(&next_participants)
                {
                    // Begin the participant removal process.
                    self.remove_participant_after(&id, &batch.output_epoch());
                }
                if self.participants_after_change.contains(&self.our_id)
                    && !next_participants.contains(&self.our_id)
                {
                    send_last_epoch_started = true;
                }
                self.participants_after_change = next_participants;
            }
        }
        if !self.is_removed || send_last_epoch_started {
            // Announce the new epoch.
            let msg = Message::EpochStarted(self.algo.epoch());
            Target::all().message(msg).into()
        } else {
            // If removed, do not announce the new epoch to prevent peers from sending messages to
            // this node.
            Step::<D>::default()
        }
    }
fn update_epoch ( & mut self , step : & CpStep < D > ) -> CpStep < Self > { if step . output . is_empty ( ) { return Step :: < D > :: default ( ) ; } // If this node removes itself after this epoch, it should send an `EpochStarted` with the // next epoch and then go offline. let mut send_last_epoch_started = false ; // Look up `DynamicHoneyBadger` epoch updates and collect any added peers. for batch in & step . output { if let Some ( next_participants ) = batch . participant_change ( ) { // Insert candidates. for id in & next_participants { if id != self . our_id ( ) { self . peer_epochs . entry ( id . clone ( ) ) . or_default ( ) ; if let Some ( & last ) = self . last_epochs . get ( id ) { if last < batch . output_epoch ( ) { self . last_epochs . remove ( id ) ; } } } } debug ! ( " " self participants_after_change ) ; debug ! ( " " next_participants ) ; // Remove obsolete participants. for id in self . participants_after_change . clone ( ) . difference ( & next_participants ) { // Begin the participant removal process. self . remove_participant_after ( & id , & batch . output_epoch ( ) ) ; } if self . participants_after_change . contains ( & self . our_id ) && ! next_participants . contains ( & self . our_id ) { send_last_epoch_started = true ; } self . participants_after_change = next_participants ; } } if ! self . is_removed || send_last_epoch_started { // Announce the new epoch. let msg = Message :: EpochStarted ( self . algo . epoch ( ) ) ; Target :: all ( ) . message ( msg ) . into ( ) } else { // If removed, do not announce the new epoch to prevent peers from sending messages to // this node. Step :: < D > :: default ( ) } }
Updates the current Honey Badger epoch.
Updates the current Honey Badger epoch .
&mut self
step
&CpStep<D>