Consensus

Trait Consensus 

Source
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§

Source

type Error

The error type related to consensus.

Required Methods§

Source

fn validate_body_against_header( &self, body: &B::Body, header: &SealedHeader<B::Header>, ) -> Result<(), Self::Error>

Ensures that body field values match the header.

Source

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 T
where &'a T: HeaderValidator<B::Header>,

Source§

type Error = <T as Consensus<B>>::Error

Source§

fn validate_body_against_header( &self, body: &B::Body, header: &SealedHeader<B::Header>, ) -> Result<(), Self::Error>

Source§

fn validate_block_pre_execution( &self, block: &SealedBlock<B>, ) -> Result<(), Self::Error>

Source§

impl<B: Block, T: Consensus<B> + ?Sized> Consensus<B> for Arc<T>
where Arc<T>: HeaderValidator<B::Header>,

Source§

type Error = <T as Consensus<B>>::Error

Source§

fn validate_body_against_header( &self, body: &B::Body, header: &SealedHeader<B::Header>, ) -> Result<(), Self::Error>

Source§

fn validate_block_pre_execution( &self, block: &SealedBlock<B>, ) -> Result<(), Self::Error>

Implementors§

Source§

impl<B: Block> Consensus<B> for NoopConsensus

Source§

impl<B: Block> Consensus<B> for TestConsensus

Available on crate features test-utils only.