pub trait BlockReader:
BlockNumReader
+ HeaderProvider
+ TransactionsProvider
+ ReceiptProvider
+ 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§
Sourcefn find_block_by_hash(
&self,
hash: B256,
source: BlockSource,
) -> ProviderResult<Option<Block>>
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.
Sourcefn block(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Block>>
fn block(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Block>>
Returns the block with given id from the database.
Returns None
if block is not found.
Sourcefn pending_block(&self) -> ProviderResult<Option<SealedBlock>>
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.
Sourcefn pending_block_with_senders(
&self,
) -> ProviderResult<Option<SealedBlockWithSenders>>
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.
Sourcefn pending_block_and_receipts(
&self,
) -> ProviderResult<Option<(SealedBlock, Vec<Receipt>)>>
fn pending_block_and_receipts( &self, ) -> ProviderResult<Option<(SealedBlock, Vec<Receipt>)>>
Returns the pending block and receipts if available.
Sourcefn ommers(&self, id: BlockHashOrNumber) -> ProviderResult<Option<Vec<Header>>>
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.
Sourcefn block_body_indices(
&self,
num: u64,
) -> ProviderResult<Option<StoredBlockBodyIndices>>
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.
Sourcefn block_with_senders(
&self,
id: BlockHashOrNumber,
transaction_kind: TransactionVariant,
) -> ProviderResult<Option<BlockWithSenders>>
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.
Sourcefn sealed_block_with_senders(
&self,
id: BlockHashOrNumber,
transaction_kind: TransactionVariant,
) -> ProviderResult<Option<SealedBlockWithSenders>>
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.
Sourcefn block_range(
&self,
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<Vec<Block>>
fn block_range( &self, range: RangeInclusive<BlockNumber>, ) -> ProviderResult<Vec<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>>
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.
Sourcefn sealed_block_with_senders_range(
&self,
range: RangeInclusive<BlockNumber>,
) -> ProviderResult<Vec<SealedBlockWithSenders>>
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§
Sourcefn block_by_hash(&self, hash: B256) -> ProviderResult<Option<Block>>
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.
Sourcefn block_by_number(&self, num: u64) -> ProviderResult<Option<Block>>
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.
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.