pub(crate) fn on_new_unit(
        &mut self,
        uhash: &C::Hash,
        now: Timestamp,
        state: &State<C>,
        instance_id: C::InstanceId,
    ) -> Vec<Effect<C>> {
        if let Some(fault) = state.maybe_fault(self.vidx) {
            return vec![Effect::WeAreFaulty(fault.clone())];
        }
        let mut effects = vec![];
        if self.should_send_confirmation(uhash, now, state) {
            let panorama = state.confirmation_panorama(self.vidx, uhash);
            if panorama.has_correct() {
                if let Some(confirmation_unit) =
                    self.new_unit(panorama, now, None, state, instance_id)
                {
                    let vv = ValidVertex(Vertex::Unit(confirmation_unit));
                    effects.push(Effect::NewVertex(vv));
                }
            }
        };
        if self.should_endorse(uhash, state) {
            let endorsement = self.endorse(uhash);
            effects.extend(vec![Effect::NewVertex(ValidVertex(endorsement))]);
        }
        effects
    }
/// Returns actions a validator needs to take upon receiving a new unit.
Returns actions a validator needs to take upon receiving a new unit.
Returns actions a validator needs to take upon receiving a new unit .
pub(crate) fn on_new_unit(
        &mut self,
        uhash: &C::Hash,
        now: Timestamp,
        state: &State<C>,
        instance_id: C::InstanceId,
    ) -> Vec<Effect<C>> {
        if let Some(fault) = state.maybe_fault(self.vidx) {
            return vec![Effect::WeAreFaulty(fault.clone())];
        }
        let mut effects = vec![];
        if self.should_send_confirmation(uhash, now, state) {
            let panorama = state.confirmation_panorama(self.vidx, uhash);
            if panorama.has_correct() {
                if let Some(confirmation_unit) =
                    self.new_unit(panorama, now, None, state, instance_id)
                {
                    let vv = ValidVertex(Vertex::Unit(confirmation_unit));
                    effects.push(Effect::NewVertex(vv));
                }
            }
        };
        if self.should_endorse(uhash, state) {
            let endorsement = self.endorse(uhash);
            effects.extend(vec![Effect::NewVertex(ValidVertex(endorsement))]);
        }
        effects
    }
pub ( crate ) fn on_new_unit ( & mut self , uhash : & C :: Hash , now : Timestamp , state : & State < C > , instance_id : C :: InstanceId , ) -> Vec < Effect < C > > { if let Some ( fault ) = state . maybe_fault ( self . vidx ) { return vec ! [ Effect WeAreFaulty ( fault clone ( ) ) ] ; } let mut effects = vec ! [ ] ; if self . should_send_confirmation ( uhash , now , state ) { let panorama = state . confirmation_panorama ( self . vidx , uhash ) ; if panorama . has_correct ( ) { if let Some ( confirmation_unit ) = self . new_unit ( panorama , now , None , state , instance_id ) { let vv = ValidVertex ( Vertex :: Unit ( confirmation_unit ) ) ; effects . push ( Effect :: NewVertex ( vv ) ) ; } } } ; if self . should_endorse ( uhash , state ) { let endorsement = self . endorse ( uhash ) ; effects . extend ( vec ! [ Effect NewVertex ( ValidVertex ( endorsement ) ) ] ) ; } effects }
Returns actions a validator needs to take upon receiving a new unit.
Returns actions a validator needs to take upon receiving a new unit .
&mut self
uhash
&C::Hash
now
Timestamp
state
&State<C>
instance_id
C::InstanceId
&mut self
uhash
&C::Hash
now
Timestamp
state
&State<C>
instance_id
C::InstanceId