pub fn apply_block(
		&self,
		operation: &mut ClientImportOperation<Block, Blake2Hasher, B>,
		import_block: ImportBlock<Block>,
		new_cache: HashMap<CacheKeyId, Vec<u8>>,
	) -> error::Result<ImportResult> where
		E: CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone,
	{
		use runtime_primitives::traits::Digest;

		let ImportBlock {
			origin,
			header,
			justification,
			post_digests,
			body,
			finalized,
			auxiliary,
			fork_choice,
		} = import_block;

		assert!(justification.is_some() && finalized || justification.is_none());

		let parent_hash = header.parent_hash().clone();

		match self.backend.blockchain().status(BlockId::Hash(parent_hash))? {
			blockchain::BlockStatus::InChain => {},
			blockchain::BlockStatus::Unknown => return Ok(ImportResult::UnknownParent),
		}

		let import_headers = if post_digests.is_empty() {
			PrePostHeader::Same(header)
		} else {
			let mut post_header = header.clone();
			for item in post_digests {
				post_header.digest_mut().push(item);
			}
			PrePostHeader::Different(header, post_header)
		};

		let hash = import_headers.post().hash();
		let height: u64 = import_headers.post().number().as_();

		*self.importing_block.write() = Some(hash);

		let result = self.execute_and_import_block(
			operation,
			origin,
			hash,
			import_headers,
			justification,
			body,
			new_cache,
			finalized,
			auxiliary,
			fork_choice,
		);

		telemetry!(SUBSTRATE_INFO; "block.import";
			"height" => height,
			"best" => ?hash,
			"origin" => ?origin
		);

		result
	}
/// Apply a checked and validated block to an operation. If a justification is provided
/// then `finalized` *must* be true.
Apply a checked and validated block to an operation. If a justification is provided
then `finalized` *must* be true.
Apply a checked and validated block to an operation . If a justification is provided then ` finalized ` * must * be true .
pub fn apply_block(
		&self,
		operation: &mut ClientImportOperation<Block, Blake2Hasher, B>,
		import_block: ImportBlock<Block>,
		new_cache: HashMap<CacheKeyId, Vec<u8>>,
	) -> error::Result<ImportResult> where
		E: CallExecutor<Block, Blake2Hasher> + Send + Sync + Clone,
	{
		use runtime_primitives::traits::Digest;
		let ImportBlock {
			origin,
			header,
			justification,
			post_digests,
			body,
			finalized,
			auxiliary,
			fork_choice,
		} = import_block;
		assert!(justification.is_some() && finalized || justification.is_none());
		let parent_hash = header.parent_hash().clone();
		match self.backend.blockchain().status(BlockId::Hash(parent_hash))? {
			blockchain::BlockStatus::InChain => {},
			blockchain::BlockStatus::Unknown => return Ok(ImportResult::UnknownParent),
		}
		let import_headers = if post_digests.is_empty() {
			PrePostHeader::Same(header)
		} else {
			let mut post_header = header.clone();
			for item in post_digests {
				post_header.digest_mut().push(item);
			}
			PrePostHeader::Different(header, post_header)
		};
		let hash = import_headers.post().hash();
		let height: u64 = import_headers.post().number().as_();
		*self.importing_block.write() = Some(hash);
		let result = self.execute_and_import_block(
			operation,
			origin,
			hash,
			import_headers,
			justification,
			body,
			new_cache,
			finalized,
			auxiliary,
			fork_choice,
		);
		telemetry!(SUBSTRATE_INFO; "block.import";
			"height" => height,
			"best" => ?hash,
			"origin" => ?origin
		);
		result
	}
pub fn apply_block ( & self , operation : & mut ClientImportOperation < Block , Blake2Hasher , B > , import_block : ImportBlock < Block > , new_cache : HashMap < CacheKeyId , Vec < u8 > > , ) -> error :: Result < ImportResult > where E : CallExecutor < Block , Blake2Hasher > + Send + Sync + Clone , { use runtime_primitives :: traits :: Digest ; let ImportBlock { origin , header , justification , post_digests , body , finalized , auxiliary , fork_choice , } = import_block ; assert ! ( justification is_some ( ) finalized justification is_none ( ) ) ; let parent_hash = header . parent_hash ( ) . clone ( ) ; match self . backend . blockchain ( ) . status ( BlockId :: Hash ( parent_hash ) ) ? { blockchain :: BlockStatus :: InChain => { } , blockchain :: BlockStatus :: Unknown => return Ok ( ImportResult :: UnknownParent ) , } let import_headers = if post_digests . is_empty ( ) { PrePostHeader :: Same ( header ) } else { let mut post_header = header . clone ( ) ; for item in post_digests { post_header . digest_mut ( ) . push ( item ) ; } PrePostHeader :: Different ( header , post_header ) } ; let hash = import_headers . post ( ) . hash ( ) ; let height : u64 = import_headers . post ( ) . number ( ) . as_ ( ) ; * self . importing_block . write ( ) = Some ( hash ) ; let result = self . execute_and_import_block ( operation , origin , hash , import_headers , justification , body , new_cache , finalized , auxiliary , fork_choice , ) ; telemetry ! ( SUBSTRATE_INFO " " " " height " " hash " " origin ) ; result }
Apply a checked and validated block to an operation.
Apply a checked and validated block to an operation .
&self
operation
&mut ClientImportOperation<Block, Blake2Hasher, B>
import_block
ImportBlock<Block>
new_cache
HashMap<CacheKeyId, Vec<u8>>
&self
operation
&mut ClientImportOperation<Block, Blake2Hasher, B>
import_block
ImportBlock<Block>
new_cache
HashMap<CacheKeyId, Vec<u8>>