pub(crate) fn finalize<F: Fn(N) -> ::client::error::Result<Option<H>>>(
		&mut self,
		block: (N, H),
		canonical_at_height: F,
	) -> ::client::error::Result<(bool, bool)> {
		let (split_idx, has_finalized_changes) = self.pending_changes.iter()
			.enumerate()
			.take_while(|(_, &(at_height, _))| at_height <= block.0)
			.fold((None, Ok(false)), |(_, has_finalized_changes), (idx, ref at)|
				(
					Some(idx),
					has_finalized_changes
						.and_then(|has_finalized_changes| if has_finalized_changes {
							Ok(has_finalized_changes)
						} else {
							canonical_at_height(at.0).map(|can_hash| Some(at.1) == can_hash)
						}),
				));

		let altered_changes = split_idx.is_some();
		if let Some(split_idx) = split_idx {
			self.pending_changes = self.pending_changes.split_off(split_idx + 1);
		}
		has_finalized_changes.map(|has_finalized_changes| (altered_changes, has_finalized_changes))
	}
/// Finalize all pending consensus changes that are finalized by given block.
/// Returns true if there any changes were finalized.
Finalize all pending consensus changes that are finalized by given block.
Returns true if there any changes were finalized.
Finalize all pending consensus changes that are finalized by given block . Returns true if there any changes were finalized .
pub(crate) fn finalize<F: Fn(N) -> ::client::error::Result<Option<H>>>(
		&mut self,
		block: (N, H),
		canonical_at_height: F,
	) -> ::client::error::Result<(bool, bool)> {
		let (split_idx, has_finalized_changes) = self.pending_changes.iter()
			.enumerate()
			.take_while(|(_, &(at_height, _))| at_height <= block.0)
			.fold((None, Ok(false)), |(_, has_finalized_changes), (idx, ref at)|
				(
					Some(idx),
					has_finalized_changes
						.and_then(|has_finalized_changes| if has_finalized_changes {
							Ok(has_finalized_changes)
						} else {
							canonical_at_height(at.0).map(|can_hash| Some(at.1) == can_hash)
						}),
				));
		let altered_changes = split_idx.is_some();
		if let Some(split_idx) = split_idx {
			self.pending_changes = self.pending_changes.split_off(split_idx + 1);
		}
		has_finalized_changes.map(|has_finalized_changes| (altered_changes, has_finalized_changes))
	}
pub ( crate ) fn finalize < F : Fn ( N ) -> :: client :: error :: Result < Option < H > > > ( & mut self , block : ( N , H ) , canonical_at_height : F , ) -> :: client :: error :: Result < ( bool , bool ) > { let ( split_idx , has_finalized_changes ) = self . pending_changes . iter ( ) . enumerate ( ) . take_while ( | ( _ , & ( at_height , _ ) ) | at_height <= block . 0 ) . fold ( ( None , Ok ( false ) ) , | ( _ , has_finalized_changes ) , ( idx , ref at ) | ( Some ( idx ) , has_finalized_changes . and_then ( | has_finalized_changes | if has_finalized_changes { Ok ( has_finalized_changes ) } else { canonical_at_height ( at . 0 ) . map ( | can_hash | Some ( at . 1 ) == can_hash ) } ) , ) ) ; let altered_changes = split_idx . is_some ( ) ; if let Some ( split_idx ) = split_idx { self . pending_changes = self . pending_changes . split_off ( split_idx + 1 ) ; } has_finalized_changes . map ( | has_finalized_changes | ( altered_changes , has_finalized_changes ) ) }
Finalize all pending consensus changes that are finalized by given block.
Finalize all pending consensus changes that are finalized by given block .
&mut self
block
(N, H)
canonical_at_height
F
&mut self
block
(N, H)
canonical_at_height
F