Skip to main content

FinalizedBlocksProvider

Trait FinalizedBlocksProvider 

Source
pub(crate) trait FinalizedBlocksProvider: Send + Sync {
    // Required methods
    fn finalized_height(&self) -> Option<u64>;
    fn block_by_height(&self, height: u64) -> ProviderResult<Option<Block>>;
    fn block_by_hash(&self, hash: B256) -> ProviderResult<Option<Block>>;
}
Expand description

Narrow view of reth that Hybrid needs: a finalized watermark and canonical-by-height / canonical-by-hash block reads.

Exists to make unit testing easier. [BlockchainProvider] is used in production.

Required Methods§

Source

fn finalized_height(&self) -> Option<u64>

Reth’s last finalized block height, or None if reth has not yet finalized anything (fresh chain).

Source

fn block_by_height(&self, height: u64) -> ProviderResult<Option<Block>>

Look up a finalized block by height in reth.

Implementations MUST return None for any height above Self::finalized_height (and unconditionally when Self::finalized_height is None); the marshal relies on Hybrid only serving blocks reth has marked as finalized.

Source

fn block_by_hash(&self, hash: B256) -> ProviderResult<Option<Block>>

Look up a finalized block by hash in reth.

Implementations MUST restrict the lookup to canonical blocks only — pending/in-flight blocks must never be returned, otherwise the marshal could be handed a non-finalized block.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<N> FinalizedBlocksProvider for BlockchainProvider<N>
where N: ProviderNodeTypes, Self: BlockReader<Block = Block>,

Production impl over reth’s [BlockchainProvider] — the only type passed to Hybrid in production. Generic over N only so the impl works for any concrete BlockchainProvider<N> whose primitive block type is tempo_primitives::Block (e.g. the BlockchainProvider<NodeTypesWithDBAdapter<TempoNode, DatabaseEnv>> alias used by tempo_node::TempoFullNode).

Source§

fn finalized_height(&self) -> Option<u64>

Source§

fn block_by_height(&self, height: u64) -> ProviderResult<Option<Block>>

Source§

fn block_by_hash(&self, hash: B256) -> ProviderResult<Option<Block>>

Implementors§