pub fn uncles(&self, target_hash: Block::Hash, max_generation: NumberFor<Block>) -> error::Result<Vec<Block::Hash>> {
		let load_header = |id: Block::Hash| -> error::Result<Block::Header> {
			match self.backend.blockchain().header(BlockId::Hash(id))? {
				Some(hdr) => Ok(hdr),
				None => Err(ErrorKind::UnknownBlock(format!("Unknown block {:?}", id)).into()),
			}
		};

		let genesis_hash = self.backend.blockchain().info()?.genesis_hash;
		if genesis_hash == target_hash { return Ok(Vec::new()); }

		let mut current_hash = target_hash;
		let mut current = load_header(current_hash)?;
		let mut ancestor_hash = *current.parent_hash();
		let mut ancestor = load_header(ancestor_hash)?;
		let mut uncles = Vec::new();

		for _generation in 0..max_generation.as_() {
			let children = self.backend.blockchain().children(ancestor_hash)?;
			uncles.extend(children.into_iter().filter(|h| h != &current_hash));
			current_hash = ancestor_hash;
			if genesis_hash == current_hash { break; }
			current = ancestor;
			ancestor_hash = *current.parent_hash();
			ancestor = load_header(ancestor_hash)?;
		}

		Ok(uncles)
	}
/// Gets the uncles of the block with `target_hash` going back `max_generation` ancestors.
Gets the uncles of the block with `target_hash` going back `max_generation` ancestors.
Gets the uncles of the block with ` target_hash ` going back ` max_generation ` ancestors .
pub fn uncles(&self, target_hash: Block::Hash, max_generation: NumberFor<Block>) -> error::Result<Vec<Block::Hash>> {
		let load_header = |id: Block::Hash| -> error::Result<Block::Header> {
			match self.backend.blockchain().header(BlockId::Hash(id))? {
				Some(hdr) => Ok(hdr),
				None => Err(ErrorKind::UnknownBlock(format!("Unknown block {:?}", id)).into()),
			}
		};
		let genesis_hash = self.backend.blockchain().info()?.genesis_hash;
		if genesis_hash == target_hash { return Ok(Vec::new()); }
		let mut current_hash = target_hash;
		let mut current = load_header(current_hash)?;
		let mut ancestor_hash = *current.parent_hash();
		let mut ancestor = load_header(ancestor_hash)?;
		let mut uncles = Vec::new();
		for _generation in 0..max_generation.as_() {
			let children = self.backend.blockchain().children(ancestor_hash)?;
			uncles.extend(children.into_iter().filter(|h| h != &current_hash));
			current_hash = ancestor_hash;
			if genesis_hash == current_hash { break; }
			current = ancestor;
			ancestor_hash = *current.parent_hash();
			ancestor = load_header(ancestor_hash)?;
		}
		Ok(uncles)
	}
pub fn uncles ( & self , target_hash : Block :: Hash , max_generation : NumberFor < Block > ) -> error :: Result < Vec < Block :: Hash > > { let load_header = | id : Block :: Hash | -> error :: Result < Block :: Header > { match self . backend . blockchain ( ) . header ( BlockId :: Hash ( id ) ) ? { Some ( hdr ) => Ok ( hdr ) , None => Err ( ErrorKind :: UnknownBlock ( format ! ( " " id ) ) . into ( ) ) , } } ; let genesis_hash = self . backend . blockchain ( ) . info ( ) ? . genesis_hash ; if genesis_hash == target_hash { return Ok ( Vec :: new ( ) ) ; } let mut current_hash = target_hash ; let mut current = load_header ( current_hash ) ? ; let mut ancestor_hash = * current . parent_hash ( ) ; let mut ancestor = load_header ( ancestor_hash ) ? ; let mut uncles = Vec :: new ( ) ; for _generation in 0 .. max_generation . as_ ( ) { let children = self . backend . blockchain ( ) . children ( ancestor_hash ) ? ; uncles . extend ( children . into_iter ( ) . filter ( | h | h != & current_hash ) ) ; current_hash = ancestor_hash ; if genesis_hash == current_hash { break ; } current = ancestor ; ancestor_hash = * current . parent_hash ( ) ; ancestor = load_header ( ancestor_hash ) ? ; } Ok ( uncles ) }
Gets the uncles of the block with `target_hash` going back `max_generation` ancestors.
Gets the uncles of the block with ` target_hash ` going back ` max_generation ` ancestors .
&self
target_hash
Block::Hash
max_generation
NumberFor<Block>
&self
target_hash
Block::Hash
max_generation
NumberFor<Block>