pub(crate) fn apply_standard_changes<F, E>(
		&mut self,
		finalized_hash: H,
		finalized_number: N,
		is_descendent_of: &F,
	) -> Result<Status<H, N>, fork_tree::Error<E>>
		where F: Fn(&H, &H) -> Result<bool, E>,
			  E: std::error::Error,
	{
		let mut status = Status {
			changed: false,
			new_set_block: None,
		};

		match self.pending_standard_changes.finalize_with_descendent_if(
			&finalized_hash,
			finalized_number.clone(),
			is_descendent_of,
			|change| change.effective_number() <= finalized_number
		)? {
			fork_tree::FinalizationResult::Changed(change) => {
				status.changed = true;

				// if we are able to finalize any standard change then we can
				// discard all pending forced changes (on different forks)
				self.pending_forced_changes.clear();

				if let Some(change) = change {
					info!(target: "finality", "Applying authority set change scheduled at block #{:?}",
						  change.canon_height);
					telemetry!(CONSENSUS_INFO; "afg.applying_scheduled_authority_set_change";
						"block" => ?change.canon_height
					);

					self.current_authorities = change.next_authorities;
					self.set_id += 1;

					status.new_set_block = Some((
						finalized_hash,
						finalized_number,
					));
				}
			},
			fork_tree::FinalizationResult::Unchanged => {},
		}

		Ok(status)
	}
/// Apply or prune any pending transitions based on a finality trigger. This
/// method ensures that if there are multiple changes in the same branch,
/// finalizing this block won't finalize past multiple transitions (i.e.
/// transitions must be finalized in-order). The given function
/// `is_descendent_of` should return `true` if the second hash (target) is a
/// descendent of the first hash (base).
///
/// When the set has changed, the return value will be `Ok(Some((H, N)))`
/// which is the canonical block where the set last changed (i.e. the given
/// hash and number).
Apply or prune any pending transitions based on a finality trigger. This
method ensures that if there are multiple changes in the same branch,
finalizing this block won't finalize past multiple transitions . The given function
`is_descendent_of` should return `true` if the second hash (target) is a
descendent of the first hash (base).

When the set has changed, the return value will be `Ok(Some((H, N)))`
which is the canonical block where the set last changed .
Apply or prune any pending transitions based on a finality trigger . This method ensures that if there are multiple changes in the same branch finalizing this block won ' t finalize past multiple transitions . The given function ` is_descendent_of ` should return ` true ` if the second hash ( target ) is a descendent of the first hash ( base ) . When the set has changed the return value will be ` Ok ( Some (( H N ))) ` which is the canonical block where the set last changed .
pub(crate) fn apply_standard_changes<F, E>(
		&mut self,
		finalized_hash: H,
		finalized_number: N,
		is_descendent_of: &F,
	) -> Result<Status<H, N>, fork_tree::Error<E>>
		where F: Fn(&H, &H) -> Result<bool, E>,
			  E: std::error::Error,
	{
		let mut status = Status {
			changed: false,
			new_set_block: None,
		};
		match self.pending_standard_changes.finalize_with_descendent_if(
			&finalized_hash,
			finalized_number.clone(),
			is_descendent_of,
			|change| change.effective_number() <= finalized_number
		)? {
			fork_tree::FinalizationResult::Changed(change) => {
				status.changed = true;
				// if we are able to finalize any standard change then we can
				// discard all pending forced changes (on different forks)
				self.pending_forced_changes.clear();
				if let Some(change) = change {
					info!(target: "finality", "Applying authority set change scheduled at block #{:?}",
						  change.canon_height);
					telemetry!(CONSENSUS_INFO; "afg.applying_scheduled_authority_set_change";
						"block" => ?change.canon_height
					);
					self.current_authorities = change.next_authorities;
					self.set_id += 1;
					status.new_set_block = Some((
						finalized_hash,
						finalized_number,
					));
				}
			},
			fork_tree::FinalizationResult::Unchanged => {},
		}
		Ok(status)
	}
pub ( crate ) fn apply_standard_changes < F , E > ( & mut self , finalized_hash : H , finalized_number : N , is_descendent_of : & F , ) -> Result < Status < H , N > , fork_tree :: Error < E > > where F : Fn ( & H , & H ) -> Result < bool , E > , E : std :: error :: Error , { let mut status = Status { changed : false , new_set_block : None , } ; match self . pending_standard_changes . finalize_with_descendent_if ( & finalized_hash , finalized_number . clone ( ) , is_descendent_of , | change | change . effective_number ( ) <= finalized_number ) ? { fork_tree :: FinalizationResult :: Changed ( change ) => { status . changed = true ; // if we are able to finalize any standard change then we can // discard all pending forced changes (on different forks) self . pending_forced_changes . clear ( ) ; if let Some ( change ) = change { info ! ( target " " " " change canon_height ) ; telemetry ! ( CONSENSUS_INFO " " " " change canon_height ) ; self . current_authorities = change . next_authorities ; self . set_id += 1 ; status . new_set_block = Some ( ( finalized_hash , finalized_number , ) ) ; } } , fork_tree :: FinalizationResult :: Unchanged => { } , } Ok ( status ) }
Apply or prune any pending transitions based on a finality trigger.
Apply or prune any pending transitions based on a finality trigger .
&mut self
finalized_hash
H
finalized_number
N
is_descendent_of
&F
&mut self
finalized_hash
H
finalized_number
N
is_descendent_of
&F