reth_storage_api

Trait BlockReader

Source
pub trait BlockReader:
    BlockNumReader
    + HeaderProvider
    + BlockBodyIndicesProvider
    + TransactionsProvider
    + ReceiptProvider
    + WithdrawalsProvider
    + OmmersProvider
    + Send
    + Sync {
    type Block: Block<Body: BlockBody<Transaction = Self::Transaction>, Header = Self::Header>;

    // Required methods
    fn find_block_by_hash(
        &self,
        hash: B256,
        source: BlockSource,
    ) -> ProviderResult<Option<Self::Block>>;
    fn block(
        &self,
        id: BlockHashOrNumber,
    ) -> ProviderResult<Option<Self::Block>>;
    fn pending_block(
        &self,
    ) -> ProviderResult<Option<SealedBlockFor<Self::Block>>>;
    fn pending_block_with_senders(
        &self,
    ) -> ProviderResult<Option<SealedBlockWithSenders<Self::Block>>>;
    fn pending_block_and_receipts(
        &self,
    ) -> ProviderResult<Option<(SealedBlockFor<Self::Block>, Vec<Self::Receipt>)>>;
    fn block_with_senders(
        &self,
        id: BlockHashOrNumber,
        transaction_kind: TransactionVariant,
    ) -> ProviderResult<Option<BlockWithSenders<Self::Block>>>;
    fn sealed_block_with_senders(
        &self,
        id: BlockHashOrNumber,
        transaction_kind: TransactionVariant,
    ) -> ProviderResult<Option<SealedBlockWithSenders<Self::Block>>>;
    fn block_range(
        &self,
        range: RangeInclusive<BlockNumber>,
    ) -> ProviderResult<Vec<Self::Block>>;
    fn block_with_senders_range(
        &self,
        range: RangeInclusive<BlockNumber>,
    ) -> ProviderResult<Vec<BlockWithSenders<Self::Block>>>;
    fn sealed_block_with_senders_range(
        &self,
        range: RangeInclusive<BlockNumber>,
    ) -> ProviderResult<Vec<SealedBlockWithSenders<Self::Block>>>;

    // Provided methods
    fn block_by_hash(&self, hash: B256) -> ProviderResult<Option<Self::Block>> { ... }
    fn block_by_number(&self, num: u64) -> ProviderResult<Option<Self::Block>> { ... }
}
Expand description

Api trait for fetching Block related data.

If not requested otherwise, implementers of this trait should prioritize fetching blocks from the database.

Required Associated Types§

Source

type Block: Block<Body: BlockBody<Transaction = Self::Transaction>, Header = Self::Header>

The block type this provider reads.

Required Methods§

Source

fn find_block_by_hash( &self, hash: B256, source: BlockSource, ) -> ProviderResult<Option<Self::Block>>

Tries to find in the given block source.

Note: this only operates on the hash because the number might be ambiguous.

Returns None if block is not found.

Source

fn block(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Self::Block>>

Returns the block with given id from the database.

Returns None if block is not found.

Source

fn pending_block(&self) -> ProviderResult<Option<SealedBlockFor<Self::Block>>>

Returns the pending block if available

Note: This returns a [SealedBlockFor] because it’s expected that this is sealed by the provider and the caller does not know the hash.

Source

fn pending_block_with_senders( &self, ) -> ProviderResult<Option<SealedBlockWithSenders<Self::Block>>>

Returns the pending block if available

Note: This returns a [SealedBlockWithSenders] because it’s expected that this is sealed by the provider and the caller does not know the hash.

Source

fn pending_block_and_receipts( &self, ) -> ProviderResult<Option<(SealedBlockFor<Self::Block>, Vec<Self::Receipt>)>>

Returns the pending block and receipts if available.

Source

fn block_with_senders( &self, id: BlockHashOrNumber, transaction_kind: TransactionVariant, ) -> ProviderResult<Option<BlockWithSenders<Self::Block>>>

Returns the block with senders with matching number or hash from database.

Returns the block’s transactions in the requested variant.

Returns None if block is not found.

Source

fn sealed_block_with_senders( &self, id: BlockHashOrNumber, transaction_kind: TransactionVariant, ) -> ProviderResult<Option<SealedBlockWithSenders<Self::Block>>>

Returns the sealed block with senders with matching number or hash from database.

Returns the block’s transactions in the requested variant.

Returns None if block is not found.

Source

fn block_range( &self, range: RangeInclusive<BlockNumber>, ) -> ProviderResult<Vec<Self::Block>>

Returns all blocks in the given inclusive range.

Note: returns only available blocks

Source

fn block_with_senders_range( &self, range: RangeInclusive<BlockNumber>, ) -> ProviderResult<Vec<BlockWithSenders<Self::Block>>>

Returns a range of blocks from the database, along with the senders of each transaction in the blocks.

Source

fn sealed_block_with_senders_range( &self, range: RangeInclusive<BlockNumber>, ) -> ProviderResult<Vec<SealedBlockWithSenders<Self::Block>>>

Returns a range of sealed blocks from the database, along with the senders of each transaction in the blocks.

Provided Methods§

Source

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

Returns the block with matching hash from the database.

Returns None if block is not found.

Source

fn block_by_number(&self, num: u64) -> ProviderResult<Option<Self::Block>>

Returns the block with matching number from database.

Returns None if block is not found.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl<T: BlockReader> BlockReader for &T

Source§

type Block = <T as BlockReader>::Block

Source§

fn find_block_by_hash( &self, hash: B256, source: BlockSource, ) -> ProviderResult<Option<Self::Block>>

Source§

fn block(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Self::Block>>

Source§

fn pending_block(&self) -> ProviderResult<Option<SealedBlockFor<Self::Block>>>

Source§

fn pending_block_with_senders( &self, ) -> ProviderResult<Option<SealedBlockWithSenders<Self::Block>>>

Source§

fn pending_block_and_receipts( &self, ) -> ProviderResult<Option<(SealedBlockFor<Self::Block>, Vec<Self::Receipt>)>>

Source§

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

Source§

fn block_by_number(&self, num: u64) -> ProviderResult<Option<Self::Block>>

Source§

fn block_with_senders( &self, id: BlockHashOrNumber, transaction_kind: TransactionVariant, ) -> ProviderResult<Option<BlockWithSenders<Self::Block>>>

Source§

fn sealed_block_with_senders( &self, id: BlockHashOrNumber, transaction_kind: TransactionVariant, ) -> ProviderResult<Option<SealedBlockWithSenders<Self::Block>>>

Source§

fn block_range( &self, range: RangeInclusive<BlockNumber>, ) -> ProviderResult<Vec<Self::Block>>

Source§

fn block_with_senders_range( &self, range: RangeInclusive<BlockNumber>, ) -> ProviderResult<Vec<BlockWithSenders<Self::Block>>>

Source§

fn sealed_block_with_senders_range( &self, range: RangeInclusive<BlockNumber>, ) -> ProviderResult<Vec<SealedBlockWithSenders<Self::Block>>>

Source§

impl<T: BlockReader> BlockReader for Arc<T>

Source§

type Block = <T as BlockReader>::Block

Source§

fn find_block_by_hash( &self, hash: B256, source: BlockSource, ) -> ProviderResult<Option<Self::Block>>

Source§

fn block(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Self::Block>>

Source§

fn pending_block(&self) -> ProviderResult<Option<SealedBlockFor<Self::Block>>>

Source§

fn pending_block_with_senders( &self, ) -> ProviderResult<Option<SealedBlockWithSenders<Self::Block>>>

Source§

fn pending_block_and_receipts( &self, ) -> ProviderResult<Option<(SealedBlockFor<Self::Block>, Vec<Self::Receipt>)>>

Source§

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

Source§

fn block_by_number(&self, num: u64) -> ProviderResult<Option<Self::Block>>

Source§

fn block_with_senders( &self, id: BlockHashOrNumber, transaction_kind: TransactionVariant, ) -> ProviderResult<Option<BlockWithSenders<Self::Block>>>

Source§

fn sealed_block_with_senders( &self, id: BlockHashOrNumber, transaction_kind: TransactionVariant, ) -> ProviderResult<Option<SealedBlockWithSenders<Self::Block>>>

Source§

fn block_range( &self, range: RangeInclusive<BlockNumber>, ) -> ProviderResult<Vec<Self::Block>>

Source§

fn block_with_senders_range( &self, range: RangeInclusive<BlockNumber>, ) -> ProviderResult<Vec<BlockWithSenders<Self::Block>>>

Source§

fn sealed_block_with_senders_range( &self, range: RangeInclusive<BlockNumber>, ) -> ProviderResult<Vec<SealedBlockWithSenders<Self::Block>>>

Implementors§

Source§

impl<C: Send + Sync, N: NodePrimitives> BlockReader for NoopProvider<C, N>

Source§

type Block = <N as NodePrimitives>::Block