fn notify(&mut self, last_state: RoundState<H, N>, new_state: RoundState<H, N>) {
		if last_state != new_state {
			if let Some(ref b) = self.bridged_round_state {
				b.update(new_state.clone());
			}
		}

		// send notification only when the round is completable and we've cast votes.
		// this is a workaround that ensures when we re-instantiate the voter after
		// a shutdown, we never re-create the same round with a base that was finalized
		// in this round or after.
		// we try to notify if either the round state changed or if we haven't
		// sent any notification yet (this is to guard against seeing enough
		// votes to finalize before having precommited)
		let state_changed = last_state.finalized != new_state.finalized;
		let sent_finality_notifications = self.best_finalized.is_some();

		if new_state.completable && (state_changed || !sent_finality_notifications) {
			let precommitted = matches!(self.state, Some(State::Precommitted));
			// we only cast votes when we have access to the previous round state,
			// which won't be the case whenever we catch up to a later round.
			let cant_vote = self.last_round_state.is_none();

			if precommitted || cant_vote {
				if let Some((f_hash, f_number)) = new_state.finalized {
					let commit = Commit {
						target_hash: f_hash.clone(),
						target_number: f_number,
						precommits: self.votes.finalizing_precommits(&*self.env)
							.expect("always returns none if something was finalized; this is checked above; qed")
							.collect(),
					};
					let finalized = (f_hash, f_number, self.votes.number(), commit.clone());
					let _ = self.finalized_sender.unbounded_send(finalized);
					self.best_finalized = Some(commit);
				}
			}
		}
	}
// notify when new blocks are finalized or when the round-estimate is updated
notify when new blocks are finalized or when the round-estimate is updated
notify when new blocks are finalized or when the round - estimate is updated
fn notify(&mut self, last_state: RoundState<H, N>, new_state: RoundState<H, N>) {
		if last_state != new_state {
			if let Some(ref b) = self.bridged_round_state {
				b.update(new_state.clone());
			}
		}
		// send notification only when the round is completable and we've cast votes.
		// this is a workaround that ensures when we re-instantiate the voter after
		// a shutdown, we never re-create the same round with a base that was finalized
		// in this round or after.
		// we try to notify if either the round state changed or if we haven't
		// sent any notification yet (this is to guard against seeing enough
		// votes to finalize before having precommited)
		let state_changed = last_state.finalized != new_state.finalized;
		let sent_finality_notifications = self.best_finalized.is_some();
		if new_state.completable && (state_changed || !sent_finality_notifications) {
			let precommitted = matches!(self.state, Some(State::Precommitted));
			// we only cast votes when we have access to the previous round state,
			// which won't be the case whenever we catch up to a later round.
			let cant_vote = self.last_round_state.is_none();
			if precommitted || cant_vote {
				if let Some((f_hash, f_number)) = new_state.finalized {
					let commit = Commit {
						target_hash: f_hash.clone(),
						target_number: f_number,
						precommits: self.votes.finalizing_precommits(&*self.env)
							.expect("always returns none if something was finalized; this is checked above; qed")
							.collect(),
					};
					let finalized = (f_hash, f_number, self.votes.number(), commit.clone());
					let _ = self.finalized_sender.unbounded_send(finalized);
					self.best_finalized = Some(commit);
				}
			}
		}
	}
fn notify ( & mut self , last_state : RoundState < H , N > , new_state : RoundState < H , N > ) { if last_state != new_state { if let Some ( ref b ) = self . bridged_round_state { b . update ( new_state . clone ( ) ) ; } } // send notification only when the round is completable and we've cast votes. // this is a workaround that ensures when we re-instantiate the voter after // a shutdown, we never re-create the same round with a base that was finalized // in this round or after. // we try to notify if either the round state changed or if we haven't // sent any notification yet (this is to guard against seeing enough // votes to finalize before having precommited) let state_changed = last_state . finalized != new_state . finalized ; let sent_finality_notifications = self . best_finalized . is_some ( ) ; if new_state . completable && ( state_changed || ! sent_finality_notifications ) { let precommitted = matches ! ( self state Some ( State Precommitted ) ) ; // we only cast votes when we have access to the previous round state, // which won't be the case whenever we catch up to a later round. let cant_vote = self . last_round_state . is_none ( ) ; if precommitted || cant_vote { if let Some ( ( f_hash , f_number ) ) = new_state . finalized { let commit = Commit { target_hash : f_hash . clone ( ) , target_number : f_number , precommits : self . votes . finalizing_precommits ( & * self . env ) . expect ( " " ) . collect ( ) , } ; let finalized = ( f_hash , f_number , self . votes . number ( ) , commit . clone ( ) ) ; let _ = self . finalized_sender . unbounded_send ( finalized ) ; self . best_finalized = Some ( commit ) ; } } } }
notify when new blocks are finalized or when the round-estimate is updated
notify when new blocks are finalized or when the round - estimate is updated
&mut self
last_state
RoundState<H, N>
new_state
RoundState<H, N>
&mut self
last_state
RoundState<H, N>
new_state
RoundState<H, N>