pub trait Consensus<B: Block>: HeaderValidator<B::Header> {
type Error;
// Required methods
fn validate_body_against_header(
&self,
body: &B::Body,
header: &SealedHeader<B::Header>,
) -> Result<(), Self::Error>;
fn validate_block_pre_execution(
&self,
block: &SealedBlock<B>,
) -> Result<(), Self::Error>;
}
Expand description
Consensus is a protocol that chooses canonical chain.
Required Associated Types§
Required Methods§
Sourcefn validate_body_against_header(
&self,
body: &B::Body,
header: &SealedHeader<B::Header>,
) -> Result<(), Self::Error>
fn validate_body_against_header( &self, body: &B::Body, header: &SealedHeader<B::Header>, ) -> Result<(), Self::Error>
Ensures that body field values match the header.
Sourcefn validate_block_pre_execution(
&self,
block: &SealedBlock<B>,
) -> Result<(), Self::Error>
fn validate_block_pre_execution( &self, block: &SealedBlock<B>, ) -> Result<(), Self::Error>
Validate a block disregarding world state, i.e. things that can be checked before sender recovery and execution.
See the Yellow Paper sections 4.4.2 “Holistic Validity”, 4.4.4 “Block Header Validity”. Note: Ommer Validation (previously section 11.1) has been deprecated since the Paris hard fork transition to proof of stake.
This should not be called for the genesis block.
Note: validating blocks does not include other validations of the Consensus
Implementations on Foreign Types§
Source§impl<'a, B: Block, T: 'a + Consensus<B> + ?Sized> Consensus<B> for &'a Twhere
&'a T: HeaderValidator<B::Header>,
impl<'a, B: Block, T: 'a + Consensus<B> + ?Sized> Consensus<B> for &'a Twhere
&'a T: HeaderValidator<B::Header>,
Source§impl<B: Block, T: Consensus<B> + ?Sized> Consensus<B> for Arc<T>where
Arc<T>: HeaderValidator<B::Header>,
impl<B: Block, T: Consensus<B> + ?Sized> Consensus<B> for Arc<T>where
Arc<T>: HeaderValidator<B::Header>,
Implementors§
Source§impl<B: Block> Consensus<B> for NoopConsensus
impl<B: Block> Consensus<B> for NoopConsensus
type Error = ConsensusError
Source§impl<B: Block> Consensus<B> for TestConsensus
Available on crate features test-utils
only.
impl<B: Block> Consensus<B> for TestConsensus
Available on crate features
test-utils
only.