Trait reth_storage_api::BlockReader

source ·
pub trait BlockReader:
    BlockNumReader
    + HeaderProvider
    + TransactionsProvider
    + ReceiptProvider
    + RequestsProvider
    + WithdrawalsProvider
    + Send
    + Sync {
Show 14 methods // Required methods fn find_block_by_hash( &self, hash: B256, source: BlockSource, ) -> ProviderResult<Option<Block>>; fn block(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Block>>; fn pending_block(&self) -> ProviderResult<Option<SealedBlock>>; fn pending_block_with_senders( &self, ) -> ProviderResult<Option<SealedBlockWithSenders>>; fn pending_block_and_receipts( &self, ) -> ProviderResult<Option<(SealedBlock, Vec<Receipt>)>>; fn ommers( &self, id: BlockHashOrNumber, ) -> ProviderResult<Option<Vec<Header>>>; fn block_body_indices( &self, num: u64, ) -> ProviderResult<Option<StoredBlockBodyIndices>>; fn block_with_senders( &self, id: BlockHashOrNumber, transaction_kind: TransactionVariant, ) -> ProviderResult<Option<BlockWithSenders>>; fn sealed_block_with_senders( &self, id: BlockHashOrNumber, transaction_kind: TransactionVariant, ) -> ProviderResult<Option<SealedBlockWithSenders>>; fn block_range( &self, range: RangeInclusive<BlockNumber>, ) -> ProviderResult<Vec<Block>>; fn block_with_senders_range( &self, range: RangeInclusive<BlockNumber>, ) -> ProviderResult<Vec<BlockWithSenders>>; fn sealed_block_with_senders_range( &self, range: RangeInclusive<BlockNumber>, ) -> ProviderResult<Vec<SealedBlockWithSenders>>; // Provided methods fn block_by_hash(&self, hash: B256) -> ProviderResult<Option<Block>> { ... } fn block_by_number(&self, num: u64) -> ProviderResult<Option<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 Methods§

source

fn find_block_by_hash( &self, hash: B256, source: BlockSource, ) -> ProviderResult<Option<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<Block>>

Returns the block with given id from the database.

Returns None if block is not found.

source

fn pending_block(&self) -> ProviderResult<Option<SealedBlock>>

Returns the pending block if available

Note: This returns a [SealedBlock] 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>>

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<(SealedBlock, Vec<Receipt>)>>

Returns the pending block and receipts if available.

source

fn ommers(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Vec<Header>>>

Returns the ommers/uncle headers of the given block from the database.

Returns None if block is not found.

source

fn block_body_indices( &self, num: u64, ) -> ProviderResult<Option<StoredBlockBodyIndices>>

Returns the block body indices with matching number from database.

Returns None if block is not found.

source

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

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>>

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<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>>

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>>

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<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<Block>>

Returns the block with matching number from database.

Returns None if block is not found.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<'a, T: 'a + BlockReader + ?Sized> BlockReader for &'a T

source§

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

source§

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

source§

fn pending_block(&self) -> ProviderResult<Option<SealedBlock>>

source§

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

source§

fn pending_block_and_receipts( &self, ) -> ProviderResult<Option<(SealedBlock, Vec<Receipt>)>>

source§

fn ommers(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Vec<Header>>>

source§

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

source§

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

source§

fn block_body_indices( &self, num: u64, ) -> ProviderResult<Option<StoredBlockBodyIndices>>

source§

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

source§

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

source§

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

source§

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

source§

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

source§

impl<T: BlockReader + ?Sized> BlockReader for Arc<T>

source§

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

source§

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

source§

fn pending_block(&self) -> ProviderResult<Option<SealedBlock>>

source§

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

source§

fn pending_block_and_receipts( &self, ) -> ProviderResult<Option<(SealedBlock, Vec<Receipt>)>>

source§

fn ommers(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Vec<Header>>>

source§

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

source§

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

source§

fn block_body_indices( &self, num: u64, ) -> ProviderResult<Option<StoredBlockBodyIndices>>

source§

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

source§

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

source§

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

source§

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

source§

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

Implementors§