Trait reth_provider::BlockReader
pub trait BlockReader:
BlockNumReader
+ HeaderProvider
+ TransactionsProvider
+ ReceiptProvider
+ RequestsProvider
+ WithdrawalsProvider
+ Send
+ Sync {
Show 14 methods
// Required methods
fn find_block_by_hash(
&self,
hash: FixedBytes<32>,
source: BlockSource,
) -> Result<Option<Block>, ProviderError>;
fn block(&self, id: HashOrNumber) -> Result<Option<Block>, ProviderError>;
fn pending_block(&self) -> Result<Option<SealedBlock>, ProviderError>;
fn pending_block_with_senders(
&self,
) -> Result<Option<SealedBlockWithSenders>, ProviderError>;
fn pending_block_and_receipts(
&self,
) -> Result<Option<(SealedBlock, Vec<Receipt>)>, ProviderError>;
fn ommers(
&self,
id: HashOrNumber,
) -> Result<Option<Vec<Header>>, ProviderError>;
fn block_body_indices(
&self,
num: u64,
) -> Result<Option<StoredBlockBodyIndices>, ProviderError>;
fn block_with_senders(
&self,
id: HashOrNumber,
transaction_kind: TransactionVariant,
) -> Result<Option<BlockWithSenders>, ProviderError>;
fn sealed_block_with_senders(
&self,
id: HashOrNumber,
transaction_kind: TransactionVariant,
) -> Result<Option<SealedBlockWithSenders>, ProviderError>;
fn block_range(
&self,
range: RangeInclusive<u64>,
) -> Result<Vec<Block>, ProviderError>;
fn block_with_senders_range(
&self,
range: RangeInclusive<u64>,
) -> Result<Vec<BlockWithSenders>, ProviderError>;
fn sealed_block_with_senders_range(
&self,
range: RangeInclusive<u64>,
) -> Result<Vec<SealedBlockWithSenders>, ProviderError>;
// Provided methods
fn block_by_hash(
&self,
hash: FixedBytes<32>,
) -> Result<Option<Block>, ProviderError> { ... }
fn block_by_number(&self, num: u64) -> Result<Option<Block>, ProviderError> { ... }
}
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§
fn find_block_by_hash(
&self,
hash: FixedBytes<32>,
source: BlockSource,
) -> Result<Option<Block>, ProviderError>
fn find_block_by_hash( &self, hash: FixedBytes<32>, source: BlockSource, ) -> Result<Option<Block>, ProviderError>
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.
fn block(&self, id: HashOrNumber) -> Result<Option<Block>, ProviderError>
fn block(&self, id: HashOrNumber) -> Result<Option<Block>, ProviderError>
Returns the block with given id from the database.
Returns None
if block is not found.
fn pending_block(&self) -> Result<Option<SealedBlock>, ProviderError>
fn pending_block(&self) -> Result<Option<SealedBlock>, ProviderError>
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.
fn pending_block_with_senders(
&self,
) -> Result<Option<SealedBlockWithSenders>, ProviderError>
fn pending_block_with_senders( &self, ) -> Result<Option<SealedBlockWithSenders>, ProviderError>
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.
fn pending_block_and_receipts(
&self,
) -> Result<Option<(SealedBlock, Vec<Receipt>)>, ProviderError>
fn pending_block_and_receipts( &self, ) -> Result<Option<(SealedBlock, Vec<Receipt>)>, ProviderError>
Returns the pending block and receipts if available.
fn ommers(&self, id: HashOrNumber) -> Result<Option<Vec<Header>>, ProviderError>
fn ommers(&self, id: HashOrNumber) -> Result<Option<Vec<Header>>, ProviderError>
Returns the ommers/uncle headers of the given block from the database.
Returns None
if block is not found.
fn block_body_indices(
&self,
num: u64,
) -> Result<Option<StoredBlockBodyIndices>, ProviderError>
fn block_body_indices( &self, num: u64, ) -> Result<Option<StoredBlockBodyIndices>, ProviderError>
Returns the block body indices with matching number from database.
Returns None
if block is not found.
fn block_with_senders(
&self,
id: HashOrNumber,
transaction_kind: TransactionVariant,
) -> Result<Option<BlockWithSenders>, ProviderError>
fn block_with_senders( &self, id: HashOrNumber, transaction_kind: TransactionVariant, ) -> Result<Option<BlockWithSenders>, ProviderError>
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.
fn sealed_block_with_senders(
&self,
id: HashOrNumber,
transaction_kind: TransactionVariant,
) -> Result<Option<SealedBlockWithSenders>, ProviderError>
fn sealed_block_with_senders( &self, id: HashOrNumber, transaction_kind: TransactionVariant, ) -> Result<Option<SealedBlockWithSenders>, ProviderError>
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.
fn block_range(
&self,
range: RangeInclusive<u64>,
) -> Result<Vec<Block>, ProviderError>
fn block_range( &self, range: RangeInclusive<u64>, ) -> Result<Vec<Block>, ProviderError>
Returns all blocks in the given inclusive range.
Note: returns only available blocks
fn block_with_senders_range(
&self,
range: RangeInclusive<u64>,
) -> Result<Vec<BlockWithSenders>, ProviderError>
fn block_with_senders_range( &self, range: RangeInclusive<u64>, ) -> Result<Vec<BlockWithSenders>, ProviderError>
Returns a range of blocks from the database, along with the senders of each transaction in the blocks.
fn sealed_block_with_senders_range(
&self,
range: RangeInclusive<u64>,
) -> Result<Vec<SealedBlockWithSenders>, ProviderError>
fn sealed_block_with_senders_range( &self, range: RangeInclusive<u64>, ) -> Result<Vec<SealedBlockWithSenders>, ProviderError>
Returns a range of sealed blocks from the database, along with the senders of each transaction in the blocks.
Provided Methods§
fn block_by_hash(
&self,
hash: FixedBytes<32>,
) -> Result<Option<Block>, ProviderError>
fn block_by_hash( &self, hash: FixedBytes<32>, ) -> Result<Option<Block>, ProviderError>
Returns the block with matching hash from the database.
Returns None
if block is not found.
fn block_by_number(&self, num: u64) -> Result<Option<Block>, ProviderError>
fn block_by_number(&self, num: u64) -> Result<Option<Block>, ProviderError>
Returns the block with matching number from database.
Returns None
if block is not found.
Object Safety§
Implementations on Foreign Types§
§impl<'a, T> BlockReader for &'a Twhere
T: 'a + BlockReader + ?Sized,
&'a T: BlockNumReader + HeaderProvider + TransactionsProvider + ReceiptProvider + RequestsProvider + WithdrawalsProvider + Send + Sync,
impl<'a, T> BlockReader for &'a Twhere
T: 'a + BlockReader + ?Sized,
&'a T: BlockNumReader + HeaderProvider + TransactionsProvider + ReceiptProvider + RequestsProvider + WithdrawalsProvider + Send + Sync,
fn find_block_by_hash( &self, hash: FixedBytes<32>, source: BlockSource, ) -> Result<Option<Block>, ProviderError>
fn block(&self, id: HashOrNumber) -> Result<Option<Block>, ProviderError>
fn pending_block(&self) -> Result<Option<SealedBlock>, ProviderError>
fn pending_block_with_senders( &self, ) -> Result<Option<SealedBlockWithSenders>, ProviderError>
fn pending_block_and_receipts( &self, ) -> Result<Option<(SealedBlock, Vec<Receipt>)>, ProviderError>
fn ommers(&self, id: HashOrNumber) -> Result<Option<Vec<Header>>, ProviderError>
fn block_by_hash( &self, hash: FixedBytes<32>, ) -> Result<Option<Block>, ProviderError>
fn block_by_number(&self, num: u64) -> Result<Option<Block>, ProviderError>
fn block_body_indices( &self, num: u64, ) -> Result<Option<StoredBlockBodyIndices>, ProviderError>
fn block_with_senders( &self, id: HashOrNumber, transaction_kind: TransactionVariant, ) -> Result<Option<BlockWithSenders>, ProviderError>
fn sealed_block_with_senders( &self, id: HashOrNumber, transaction_kind: TransactionVariant, ) -> Result<Option<SealedBlockWithSenders>, ProviderError>
fn block_range( &self, range: RangeInclusive<u64>, ) -> Result<Vec<Block>, ProviderError>
fn block_with_senders_range( &self, range: RangeInclusive<u64>, ) -> Result<Vec<BlockWithSenders>, ProviderError>
fn sealed_block_with_senders_range( &self, range: RangeInclusive<u64>, ) -> Result<Vec<SealedBlockWithSenders>, ProviderError>
§impl<T> BlockReader for Arc<T>where
T: BlockReader + ?Sized,
Arc<T>: BlockNumReader + HeaderProvider + TransactionsProvider + ReceiptProvider + RequestsProvider + WithdrawalsProvider + Send + Sync,
impl<T> BlockReader for Arc<T>where
T: BlockReader + ?Sized,
Arc<T>: BlockNumReader + HeaderProvider + TransactionsProvider + ReceiptProvider + RequestsProvider + WithdrawalsProvider + Send + Sync,
fn find_block_by_hash( &self, hash: FixedBytes<32>, source: BlockSource, ) -> Result<Option<Block>, ProviderError>
fn block(&self, id: HashOrNumber) -> Result<Option<Block>, ProviderError>
fn pending_block(&self) -> Result<Option<SealedBlock>, ProviderError>
fn pending_block_with_senders( &self, ) -> Result<Option<SealedBlockWithSenders>, ProviderError>
fn pending_block_and_receipts( &self, ) -> Result<Option<(SealedBlock, Vec<Receipt>)>, ProviderError>
fn ommers(&self, id: HashOrNumber) -> Result<Option<Vec<Header>>, ProviderError>
fn block_by_hash( &self, hash: FixedBytes<32>, ) -> Result<Option<Block>, ProviderError>
fn block_by_number(&self, num: u64) -> Result<Option<Block>, ProviderError>
fn block_body_indices( &self, num: u64, ) -> Result<Option<StoredBlockBodyIndices>, ProviderError>
fn block_with_senders( &self, id: HashOrNumber, transaction_kind: TransactionVariant, ) -> Result<Option<BlockWithSenders>, ProviderError>
fn sealed_block_with_senders( &self, id: HashOrNumber, transaction_kind: TransactionVariant, ) -> Result<Option<SealedBlockWithSenders>, ProviderError>
fn block_range( &self, range: RangeInclusive<u64>, ) -> Result<Vec<Block>, ProviderError>
fn block_with_senders_range( &self, range: RangeInclusive<u64>, ) -> Result<Vec<BlockWithSenders>, ProviderError>
fn sealed_block_with_senders_range( &self, range: RangeInclusive<u64>, ) -> Result<Vec<SealedBlockWithSenders>, ProviderError>
Implementors§
impl BlockReader for StaticFileProvider
impl BlockReader for MockEthProvider
test-utils
only.impl BlockReader for NoopProvider
test-utils
only.