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§
Sourcetype Block: Block<Body: BlockBody<Transaction = Self::Transaction>, Header = Self::Header>
type Block: Block<Body: BlockBody<Transaction = Self::Transaction>, Header = Self::Header>
The block type this provider reads.
Required Methods§
Sourcefn find_block_by_hash(
&self,
hash: B256,
source: BlockSource,
) -> ProviderResult<Option<Self::Block>>
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.
Sourcefn block(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Self::Block>>
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.
Sourcefn pending_block(&self) -> ProviderResult<Option<SealedBlockFor<Self::Block>>>
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.
Sourcefn pending_block_with_senders(
&self,
) -> ProviderResult<Option<SealedBlockWithSenders<Self::Block>>>
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.
Sourcefn pending_block_and_receipts(
&self,
) -> ProviderResult<Option<(SealedBlockFor<Self::Block>, Vec<Self::Receipt>)>>
fn pending_block_and_receipts( &self, ) -> ProviderResult<Option<(SealedBlockFor<Self::Block>, Vec<Self::Receipt>)>>
Returns the pending block and receipts if available.
Sourcefn block_with_senders(
&self,
id: BlockHashOrNumber,
transaction_kind: TransactionVariant,
) -> ProviderResult<Option<BlockWithSenders<Self::Block>>>
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.
Sourcefn sealed_block_with_senders(
&self,
id: BlockHashOrNumber,
transaction_kind: TransactionVariant,
) -> ProviderResult<Option<SealedBlockWithSenders<Self::Block>>>
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.
Sourcefn block_range(
&self,
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<Vec<Self::Block>>
fn block_range( &self, range: RangeInclusive<BlockNumber>, ) -> ProviderResult<Vec<Self::Block>>
Returns all blocks in the given inclusive range.
Note: returns only available blocks
Sourcefn block_with_senders_range(
&self,
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<Vec<BlockWithSenders<Self::Block>>>
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.
Sourcefn sealed_block_with_senders_range(
&self,
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<Vec<SealedBlockWithSenders<Self::Block>>>
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§
Sourcefn block_by_hash(&self, hash: B256) -> ProviderResult<Option<Self::Block>>
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.
Sourcefn block_by_number(&self, num: u64) -> ProviderResult<Option<Self::Block>>
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.