reth_blockchain_tree/
bundle.rsuse alloy_eips::ForkBlock;
use alloy_primitives::{BlockHash, BlockNumber};
use reth_provider::{BlockExecutionForkProvider, ExecutionDataProvider, ExecutionOutcome};
use std::collections::BTreeMap;
#[derive(Clone, Debug)]
pub struct BundleStateDataRef<'a> {
pub execution_outcome: &'a ExecutionOutcome,
pub sidechain_block_hashes: &'a BTreeMap<BlockNumber, BlockHash>,
pub canonical_block_hashes: &'a BTreeMap<BlockNumber, BlockHash>,
pub canonical_fork: ForkBlock,
}
impl ExecutionDataProvider for BundleStateDataRef<'_> {
fn execution_outcome(&self) -> &ExecutionOutcome {
self.execution_outcome
}
fn block_hash(&self, block_number: BlockNumber) -> Option<BlockHash> {
let block_hash = self.sidechain_block_hashes.get(&block_number).copied();
if block_hash.is_some() {
return block_hash;
}
self.canonical_block_hashes.get(&block_number).copied()
}
}
impl BlockExecutionForkProvider for BundleStateDataRef<'_> {
fn canonical_fork(&self) -> ForkBlock {
self.canonical_fork
}
}
#[derive(Clone, Debug)]
pub struct ExecutionData {
pub execution_outcome: ExecutionOutcome,
pub parent_block_hashes: BTreeMap<BlockNumber, BlockHash>,
pub canonical_fork: ForkBlock,
}
impl ExecutionDataProvider for ExecutionData {
fn execution_outcome(&self) -> &ExecutionOutcome {
&self.execution_outcome
}
fn block_hash(&self, block_number: BlockNumber) -> Option<BlockHash> {
self.parent_block_hashes.get(&block_number).copied()
}
}
impl BlockExecutionForkProvider for ExecutionData {
fn canonical_fork(&self) -> ForkBlock {
self.canonical_fork
}
}