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

		for root in self.roots.iter_mut() {
			if root.hash == hash {
				return Err(Error::Duplicate);
			}

			match root.import(hash, number, data, is_descendent_of)? {
				Some((h, n, d)) => {
					hash = h;
					number = n;
					data = d;
				},
				None => return Ok(false),
			}
		}

		self.roots.push(Node {
			data,
			hash: hash,
			number: number,
			children:  Vec::new(),
		});

		Ok(true)
	}
/// Import a new node into the tree. The given function `is_descendent_of`
/// should return `true` if the second hash (target) is a descendent of the
/// first hash (base). This method assumes that nodes in the same branch are
/// imported in order.
Import a new node into the tree. The given function `is_descendent_of`
should return `true` if the second hash (target) is a descendent of the
first hash (base). This method assumes that nodes in the same branch are
imported in order.
Import a new node into the tree . The given function ` is_descendent_of ` should return ` true ` if the second hash ( target ) is a descendent of the first hash ( base ) . This method assumes that nodes in the same branch are imported in order .
pub fn import<F, E>(
		&mut self,
		mut hash: H,
		mut number: N,
		mut data: V,
		is_descendent_of: &F,
	) -> Result<bool, Error<E>>
		where E: std::error::Error,
			  F: Fn(&H, &H) -> Result<bool, E>,
	{
		if let Some(ref best_finalized_number) = self.best_finalized_number {
			if number <= *best_finalized_number {
				return Err(Error::Revert);
			}
		}
		for root in self.roots.iter_mut() {
			if root.hash == hash {
				return Err(Error::Duplicate);
			}
			match root.import(hash, number, data, is_descendent_of)? {
				Some((h, n, d)) => {
					hash = h;
					number = n;
					data = d;
				},
				None => return Ok(false),
			}
		}
		self.roots.push(Node {
			data,
			hash: hash,
			number: number,
			children:  Vec::new(),
		});
		Ok(true)
	}
pub fn import < F , E > ( & mut self , mut hash : H , mut number : N , mut data : V , is_descendent_of : & F , ) -> Result < bool , Error < E > > where E : std :: error :: Error , F : Fn ( & H , & H ) -> Result < bool , E > , { if let Some ( ref best_finalized_number ) = self . best_finalized_number { if number <= * best_finalized_number { return Err ( Error :: Revert ) ; } } for root in self . roots . iter_mut ( ) { if root . hash == hash { return Err ( Error :: Duplicate ) ; } match root . import ( hash , number , data , is_descendent_of ) ? { Some ( ( h , n , d ) ) => { hash = h ; number = n ; data = d ; } , None => return Ok ( false ) , } } self . roots . push ( Node { data , hash : hash , number : number , children : Vec :: new ( ) , } ) ; Ok ( true ) }
Import a new node into the tree.
Import a new node into the tree .
&mut self
hash
H
number
N
data
V
is_descendent_of
&F
&mut self
hash
H
number
N
data
V
is_descendent_of
&F