pub fn finalizes_any_with_descendent_if<F, P, E>(
		&self,
		hash: &H,
		number: N,
		is_descendent_of: &F,
		predicate: P,
	) -> Result<Option<bool>, Error<E>>
		where E: std::error::Error,
			  F: Fn(&H, &H) -> Result<bool, E>,
			  P: Fn(&V) -> bool,
	{
		if let Some(ref best_finalized_number) = self.best_finalized_number {
			if number <= *best_finalized_number {
				return Err(Error::Revert);
			}
		}

		// check if the given hash is equal or a descendent of any node in the
		// tree, if we find a valid node that passes the predicate then we must
		// ensure that we're not finalizing past any of its child nodes.
		for node in self.node_iter() {
			if predicate(&node.data) {
				if node.hash == *hash || is_descendent_of(&node.hash, hash)? {
					for node in node.children.iter() {
						if node.number <= number && is_descendent_of(&node.hash, &hash)? {
							return Err(Error::UnfinalizedAncestor);
						}
					}

					return Ok(Some(self.roots.iter().any(|root| root.hash == node.hash)));
				}
			}
		}

		Ok(None)
	}
/// Checks if any node in the tree is finalized by either finalizing the
/// node itself or a child node that's not in the tree, guaranteeing that
/// the node being finalized isn't a descendent of any of the node's
/// children. Returns `Some(true)` if the node being finalized is a root,
/// `Some(false)` if the node being finalized is not a root, and `None` if
/// no node in the tree is finalized. The given `predicate` is checked on
/// the prospective finalized root and must pass for finalization to occur.
/// The given function `is_descendent_of` should return `true` if the second
/// hash (target) is a descendent of the first hash (base).
Checks if any node in the tree is finalized by either finalizing the
node itself or a child node that's not in the tree, guaranteeing that
the node being finalized isn't a descendent of any of the node's
children.
Checks if any node in the tree is finalized by either finalizing the node itself or a child node that ' s not in the tree guaranteeing that the node being finalized isn ' t a descendent of any of the node ' s children .
pub fn finalizes_any_with_descendent_if<F, P, E>(
		&self,
		hash: &H,
		number: N,
		is_descendent_of: &F,
		predicate: P,
	) -> Result<Option<bool>, Error<E>>
		where E: std::error::Error,
			  F: Fn(&H, &H) -> Result<bool, E>,
			  P: Fn(&V) -> bool,
	{
		if let Some(ref best_finalized_number) = self.best_finalized_number {
			if number <= *best_finalized_number {
				return Err(Error::Revert);
			}
		}
		// check if the given hash is equal or a descendent of any node in the
		// tree, if we find a valid node that passes the predicate then we must
		// ensure that we're not finalizing past any of its child nodes.
		for node in self.node_iter() {
			if predicate(&node.data) {
				if node.hash == *hash || is_descendent_of(&node.hash, hash)? {
					for node in node.children.iter() {
						if node.number <= number && is_descendent_of(&node.hash, &hash)? {
							return Err(Error::UnfinalizedAncestor);
						}
					}
					return Ok(Some(self.roots.iter().any(|root| root.hash == node.hash)));
				}
			}
		}
		Ok(None)
	}
pub fn finalizes_any_with_descendent_if < F , P , E > ( & self , hash : & H , number : N , is_descendent_of : & F , predicate : P , ) -> Result < Option < bool > , Error < E > > where E : std :: error :: Error , F : Fn ( & H , & H ) -> Result < bool , E > , P : Fn ( & V ) -> bool , { if let Some ( ref best_finalized_number ) = self . best_finalized_number { if number <= * best_finalized_number { return Err ( Error :: Revert ) ; } } // check if the given hash is equal or a descendent of any node in the // tree, if we find a valid node that passes the predicate then we must // ensure that we're not finalizing past any of its child nodes. for node in self . node_iter ( ) { if predicate ( & node . data ) { if node . hash == * hash || is_descendent_of ( & node . hash , hash ) ? { for node in node . children . iter ( ) { if node . number <= number && is_descendent_of ( & node . hash , & hash ) ? { return Err ( Error :: UnfinalizedAncestor ) ; } } return Ok ( Some ( self . roots . iter ( ) . any ( | root | root . hash == node . hash ) ) ) ; } } } Ok ( None ) }
Checks if any node in the tree is finalized by either finalizing the
node itself or a child node that's not in the tree, guaranteeing that
the node being finalized isn't a descendent of any of the node's
children.
Checks if any node in the tree is finalized by either finalizing the node itself or a child node that ' s not in the tree guaranteeing that the node being finalized isn ' t a descendent of any of the node ' s children .
&self
hash
&H
number
N
is_descendent_of
&F
predicate
P
&self
hash
&H
number
N
is_descendent_of
&F
predicate
P