feat: make InvalidBlockHook generic over NodePrimitives (#13105)

This commit is contained in:
Arsenii Kulikov
2024-12-03 19:38:10 +04:00
committed by GitHub
parent 7008ac22df
commit 9d5e159968
21 changed files with 133 additions and 115 deletions

View File

@ -1,35 +1,36 @@
use alloy_primitives::B256;
use reth_execution_types::BlockExecutionOutput;
use reth_primitives::{Receipt, SealedBlockWithSenders, SealedHeader};
use reth_primitives::{NodePrimitives, SealedBlockWithSenders, SealedHeader};
use reth_trie::updates::TrieUpdates;
/// An invalid block hook.
pub trait InvalidBlockHook: Send + Sync {
pub trait InvalidBlockHook<N: NodePrimitives>: Send + Sync {
/// Invoked when an invalid block is encountered.
fn on_invalid_block(
&self,
parent_header: &SealedHeader,
block: &SealedBlockWithSenders,
output: &BlockExecutionOutput<Receipt>,
parent_header: &SealedHeader<N::BlockHeader>,
block: &SealedBlockWithSenders<N::Block>,
output: &BlockExecutionOutput<N::Receipt>,
trie_updates: Option<(&TrieUpdates, B256)>,
);
}
impl<F> InvalidBlockHook for F
impl<F, N> InvalidBlockHook<N> for F
where
N: NodePrimitives,
F: Fn(
&SealedHeader,
&SealedBlockWithSenders,
&BlockExecutionOutput<Receipt>,
&SealedHeader<N::BlockHeader>,
&SealedBlockWithSenders<N::Block>,
&BlockExecutionOutput<N::Receipt>,
Option<(&TrieUpdates, B256)>,
) + Send
+ Sync,
{
fn on_invalid_block(
&self,
parent_header: &SealedHeader,
block: &SealedBlockWithSenders,
output: &BlockExecutionOutput<Receipt>,
parent_header: &SealedHeader<N::BlockHeader>,
block: &SealedBlockWithSenders<N::Block>,
output: &BlockExecutionOutput<N::Receipt>,
trie_updates: Option<(&TrieUpdates, B256)>,
) {
self(parent_header, block, output, trie_updates)