reth_blockchain_tree/
bundle.rs1use alloy_eips::ForkBlock;
4use alloy_primitives::{BlockHash, BlockNumber};
5use reth_provider::{BlockExecutionForkProvider, ExecutionDataProvider, ExecutionOutcome};
6use std::collections::BTreeMap;
7
8#[derive(Clone, Debug)]
10pub struct BundleStateDataRef<'a> {
11 pub execution_outcome: &'a ExecutionOutcome,
13 pub sidechain_block_hashes: &'a BTreeMap<BlockNumber, BlockHash>,
15 pub canonical_block_hashes: &'a BTreeMap<BlockNumber, BlockHash>,
17 pub canonical_fork: ForkBlock,
19}
20
21impl ExecutionDataProvider for BundleStateDataRef<'_> {
22 fn execution_outcome(&self) -> &ExecutionOutcome {
23 self.execution_outcome
24 }
25
26 fn block_hash(&self, block_number: BlockNumber) -> Option<BlockHash> {
27 let block_hash = self.sidechain_block_hashes.get(&block_number).copied();
28 if block_hash.is_some() {
29 return block_hash;
30 }
31
32 self.canonical_block_hashes.get(&block_number).copied()
33 }
34}
35
36impl BlockExecutionForkProvider for BundleStateDataRef<'_> {
37 fn canonical_fork(&self) -> ForkBlock {
38 self.canonical_fork
39 }
40}
41
42#[derive(Clone, Debug)]
44pub struct ExecutionData {
45 pub execution_outcome: ExecutionOutcome,
47 pub parent_block_hashes: BTreeMap<BlockNumber, BlockHash>,
51 pub canonical_fork: ForkBlock,
53}
54
55impl ExecutionDataProvider for ExecutionData {
56 fn execution_outcome(&self) -> &ExecutionOutcome {
57 &self.execution_outcome
58 }
59
60 fn block_hash(&self, block_number: BlockNumber) -> Option<BlockHash> {
61 self.parent_block_hashes.get(&block_number).copied()
62 }
63}
64
65impl BlockExecutionForkProvider for ExecutionData {
66 fn canonical_fork(&self) -> ForkBlock {
67 self.canonical_fork
68 }
69}