pub fn try_append_or_fork<S: Storage<Block, T>>(
		&self,
		storage: &S,
		parent: &ComplexBlockId<Block>,
		best_finalized_entry_block: Option<NumberFor<Block>>,
	) -> ClientResult<Option<ForkAppendResult<Block>>> {
		// try to find entries that are (possibly) surrounding the parent block
		let range = self.head.search_best_range_before(storage, parent.number)?;
		let begin = match range {
			Some((begin, _)) => begin,
			None => return Ok(None),
		};

		// check if the parent is connected to the beginning of the range
		if !chain::is_connected_to_block(storage, &parent, &begin)? {
			return Ok(None);
		}

		// the block is connected to the begin-entry. If begin is the head entry
		// => we need to append new block to the fork
		if begin == self.head.valid_from {
			return Ok(Some(ForkAppendResult::Append));
		}

		// the parent block belongs to this fork AND it is located after last finalized entry
		// => we need to make a new fork
		if best_finalized_entry_block.map(|f| begin.number > f).unwrap_or(true) {
			return Ok(Some(ForkAppendResult::Fork(begin)));
		}

		Ok(None)
	}
/// Try to append new block to the fork OR fork it.
Try to append new block to the fork OR fork it.
Try to append new block to the fork OR fork it .
pub fn try_append_or_fork<S: Storage<Block, T>>(
		&self,
		storage: &S,
		parent: &ComplexBlockId<Block>,
		best_finalized_entry_block: Option<NumberFor<Block>>,
	) -> ClientResult<Option<ForkAppendResult<Block>>> {
		// try to find entries that are (possibly) surrounding the parent block
		let range = self.head.search_best_range_before(storage, parent.number)?;
		let begin = match range {
			Some((begin, _)) => begin,
			None => return Ok(None),
		};
		// check if the parent is connected to the beginning of the range
		if !chain::is_connected_to_block(storage, &parent, &begin)? {
			return Ok(None);
		}
		// the block is connected to the begin-entry. If begin is the head entry
		// => we need to append new block to the fork
		if begin == self.head.valid_from {
			return Ok(Some(ForkAppendResult::Append));
		}
		// the parent block belongs to this fork AND it is located after last finalized entry
		// => we need to make a new fork
		if best_finalized_entry_block.map(|f| begin.number > f).unwrap_or(true) {
			return Ok(Some(ForkAppendResult::Fork(begin)));
		}
		Ok(None)
	}
pub fn try_append_or_fork < S : Storage < Block , T > > ( & self , storage : & S , parent : & ComplexBlockId < Block > , best_finalized_entry_block : Option < NumberFor < Block > > , ) -> ClientResult < Option < ForkAppendResult < Block > > > { // try to find entries that are (possibly) surrounding the parent block let range = self . head . search_best_range_before ( storage , parent . number ) ? ; let begin = match range { Some ( ( begin , _ ) ) => begin , None => return Ok ( None ) , } ; // check if the parent is connected to the beginning of the range if ! chain :: is_connected_to_block ( storage , & parent , & begin ) ? { return Ok ( None ) ; } // the block is connected to the begin-entry. If begin is the head entry // => we need to append new block to the fork if begin == self . head . valid_from { return Ok ( Some ( ForkAppendResult :: Append ) ) ; } // the parent block belongs to this fork AND it is located after last finalized entry // => we need to make a new fork if best_finalized_entry_block . map ( | f | begin . number > f ) . unwrap_or ( true ) { return Ok ( Some ( ForkAppendResult :: Fork ( begin ) ) ) ; } Ok ( None ) }
Try to append new block to the fork OR fork it.
Try to append new block to the fork OR fork it .
&self
storage
&S
parent
&ComplexBlockId<Block>
best_finalized_entry_block
Option<NumberFor<Block>>
&self
storage
&S
parent
&ComplexBlockId<Block>
best_finalized_entry_block
Option<NumberFor<Block>>