reth_consensus/
noop.rs
1use crate::{Consensus, ConsensusError, FullConsensus, HeaderValidator};
2use alloc::sync::Arc;
3use reth_execution_types::BlockExecutionResult;
4use reth_primitives_traits::{Block, NodePrimitives, RecoveredBlock, SealedBlock, SealedHeader};
5
6#[derive(Debug, Copy, Clone, Default)]
8#[non_exhaustive]
9pub struct NoopConsensus;
10
11impl NoopConsensus {
12 pub fn arc() -> Arc<Self> {
14 Arc::new(Self::default())
15 }
16}
17
18impl<H> HeaderValidator<H> for NoopConsensus {
19 fn validate_header(&self, _header: &SealedHeader<H>) -> Result<(), ConsensusError> {
20 Ok(())
21 }
22
23 fn validate_header_against_parent(
24 &self,
25 _header: &SealedHeader<H>,
26 _parent: &SealedHeader<H>,
27 ) -> Result<(), ConsensusError> {
28 Ok(())
29 }
30}
31
32impl<B: Block> Consensus<B> for NoopConsensus {
33 type Error = ConsensusError;
34
35 fn validate_body_against_header(
36 &self,
37 _body: &B::Body,
38 _header: &SealedHeader<B::Header>,
39 ) -> Result<(), Self::Error> {
40 Ok(())
41 }
42
43 fn validate_block_pre_execution(&self, _block: &SealedBlock<B>) -> Result<(), Self::Error> {
44 Ok(())
45 }
46}
47
48impl<N: NodePrimitives> FullConsensus<N> for NoopConsensus {
49 fn validate_block_post_execution(
50 &self,
51 _block: &RecoveredBlock<N::Block>,
52 _result: &BlockExecutionResult<N::Receipt>,
53 ) -> Result<(), ConsensusError> {
54 Ok(())
55 }
56}