pub fn evaluate_initial<Block: BlockT>(
	proposal: &Block,
	parent_hash: &<Block as BlockT>::Hash,
	parent_number: <<Block as BlockT>::Header as HeaderT>::Number,
) -> Result<()> {

	let encoded = Encode::encode(proposal);
	let proposal = Block::decode(&mut &encoded[..])
		.ok_or_else(|| ErrorKind::BadProposalFormat)?;

	if encoded.len() > MAX_BLOCK_SIZE {
		bail!(ErrorKind::ProposalTooLarge(encoded.len()))
	}

	if *parent_hash != *proposal.header().parent_hash() {
		bail!(ErrorKind::WrongParentHash(
			format!("{:?}", *parent_hash),
			format!("{:?}", proposal.header().parent_hash())
		));
	}

	if parent_number.as_() + 1 != proposal.header().number().as_() {
		bail!(ErrorKind::WrongNumber(parent_number.as_() + 1, proposal.header().number().as_()));
	}

	Ok(())
}
/// Attempt to evaluate a substrate block as a node block, returning error
/// upon any initial validity checks failing.
Attempt to evaluate a substrate block as a node block, returning error
upon any initial validity checks failing.
Attempt to evaluate a substrate block as a node block returning error upon any initial validity checks failing .
pub fn evaluate_initial<Block: BlockT>(
	proposal: &Block,
	parent_hash: &<Block as BlockT>::Hash,
	parent_number: <<Block as BlockT>::Header as HeaderT>::Number,
) -> Result<()> {
	let encoded = Encode::encode(proposal);
	let proposal = Block::decode(&mut &encoded[..])
		.ok_or_else(|| ErrorKind::BadProposalFormat)?;
	if encoded.len() > MAX_BLOCK_SIZE {
		bail!(ErrorKind::ProposalTooLarge(encoded.len()))
	}
	if *parent_hash != *proposal.header().parent_hash() {
		bail!(ErrorKind::WrongParentHash(
			format!("{:?}", *parent_hash),
			format!("{:?}", proposal.header().parent_hash())
		));
	}
	if parent_number.as_() + 1 != proposal.header().number().as_() {
		bail!(ErrorKind::WrongNumber(parent_number.as_() + 1, proposal.header().number().as_()));
	}
	Ok(())
}
pub fn evaluate_initial < Block : BlockT > ( proposal : & Block , parent_hash : & < Block as BlockT > :: Hash , parent_number : < < Block as BlockT > :: Header as HeaderT > :: Number , ) -> Result < ( ) > { let encoded = Encode :: encode ( proposal ) ; let proposal = Block :: decode ( & mut & encoded [ .. ] ) . ok_or_else ( | | ErrorKind :: BadProposalFormat ) ? ; if encoded . len ( ) > MAX_BLOCK_SIZE { bail ! ( ErrorKind ProposalTooLarge ( encoded len ( ) ) ) } if * parent_hash != * proposal . header ( ) . parent_hash ( ) { bail ! ( ErrorKind WrongParentHash ( format ( " " parent_hash ) format ( " " proposal header ( ) parent_hash ( ) ) ) ) ; } if parent_number . as_ ( ) + 1 != proposal . header ( ) . number ( ) . as_ ( ) { bail ! ( ErrorKind WrongNumber ( parent_number as_ ( ) 1 proposal header ( ) number ( ) as_ ( ) ) ) ; } Ok ( ( ) ) }
Attempt to evaluate a substrate block as a node block, returning error
upon any initial validity checks failing.
Attempt to evaluate a substrate block as a node block returning error upon any initial validity checks failing .
proposal
&Block
parent_hash
&<Block as BlockT>::Hash
parent_number
<<Block as BlockT>::Header as HeaderT>::Number
proposal
&Block
parent_hash
&<Block as BlockT>::Hash
parent_number
<<Block as BlockT>::Header as HeaderT>::Number