Trait BlockReader
pub trait BlockReader:
BlockNumReader
+ HeaderProvider
+ BlockBodyIndicesProvider
+ TransactionsProvider
+ ReceiptProvider
+ WithdrawalsProvider
+ OmmersProvider
+ Send
+ Sync {
type Block: Block<Header = Self::Header>
where <Self::Block as Block>::Body: BlockBody<Transaction = Self::Transaction>;
// Required methods
fn find_block_by_hash(
&self,
hash: FixedBytes<32>,
source: BlockSource,
) -> Result<Option<Self::Block>, ProviderError>;
fn block(
&self,
id: HashOrNumber,
) -> Result<Option<Self::Block>, ProviderError>;
fn pending_block(
&self,
) -> Result<Option<SealedBlock<<Self::Block as Block>::Header, <Self::Block as Block>::Body>>, ProviderError>;
fn pending_block_with_senders(
&self,
) -> Result<Option<SealedBlockWithSenders<Self::Block>>, ProviderError>;
fn pending_block_and_receipts(
&self,
) -> Result<Option<(SealedBlock<<Self::Block as Block>::Header, <Self::Block as Block>::Body>, Vec<Self::Receipt>)>, ProviderError>;
fn block_with_senders(
&self,
id: HashOrNumber,
transaction_kind: TransactionVariant,
) -> Result<Option<BlockWithSenders<Self::Block>>, ProviderError>;
fn sealed_block_with_senders(
&self,
id: HashOrNumber,
transaction_kind: TransactionVariant,
) -> Result<Option<SealedBlockWithSenders<Self::Block>>, ProviderError>;
fn block_range(
&self,
range: RangeInclusive<u64>,
) -> Result<Vec<Self::Block>, ProviderError>;
fn block_with_senders_range(
&self,
range: RangeInclusive<u64>,
) -> Result<Vec<BlockWithSenders<Self::Block>>, ProviderError>;
fn sealed_block_with_senders_range(
&self,
range: RangeInclusive<u64>,
) -> Result<Vec<SealedBlockWithSenders<Self::Block>>, ProviderError>;
// Provided methods
fn block_by_hash(
&self,
hash: FixedBytes<32>,
) -> Result<Option<Self::Block>, ProviderError> { ... }
fn block_by_number(
&self,
num: u64,
) -> Result<Option<Self::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 Associated Types§
Required Methods§
fn find_block_by_hash(
&self,
hash: FixedBytes<32>,
source: BlockSource,
) -> Result<Option<Self::Block>, ProviderError>
fn find_block_by_hash( &self, hash: FixedBytes<32>, source: BlockSource, ) -> Result<Option<Self::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<Self::Block>, ProviderError>
fn block(&self, id: HashOrNumber) -> Result<Option<Self::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<<Self::Block as Block>::Header, <Self::Block as Block>::Body>>, ProviderError>
fn pending_block( &self, ) -> Result<Option<SealedBlock<<Self::Block as Block>::Header, <Self::Block as Block>::Body>>, ProviderError>
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.
fn pending_block_with_senders(
&self,
) -> Result<Option<SealedBlockWithSenders<Self::Block>>, ProviderError>
fn pending_block_with_senders( &self, ) -> Result<Option<SealedBlockWithSenders<Self::Block>>, 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<<Self::Block as Block>::Header, <Self::Block as Block>::Body>, Vec<Self::Receipt>)>, ProviderError>
fn pending_block_and_receipts( &self, ) -> Result<Option<(SealedBlock<<Self::Block as Block>::Header, <Self::Block as Block>::Body>, Vec<Self::Receipt>)>, ProviderError>
Returns the pending block and receipts if available.
fn block_with_senders(
&self,
id: HashOrNumber,
transaction_kind: TransactionVariant,
) -> Result<Option<BlockWithSenders<Self::Block>>, ProviderError>
fn block_with_senders( &self, id: HashOrNumber, transaction_kind: TransactionVariant, ) -> Result<Option<BlockWithSenders<Self::Block>>, 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<Self::Block>>, ProviderError>
fn sealed_block_with_senders( &self, id: HashOrNumber, transaction_kind: TransactionVariant, ) -> Result<Option<SealedBlockWithSenders<Self::Block>>, 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<Self::Block>, ProviderError>
fn block_range( &self, range: RangeInclusive<u64>, ) -> Result<Vec<Self::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<Self::Block>>, ProviderError>
fn block_with_senders_range( &self, range: RangeInclusive<u64>, ) -> Result<Vec<BlockWithSenders<Self::Block>>, 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<Self::Block>>, ProviderError>
fn sealed_block_with_senders_range( &self, range: RangeInclusive<u64>, ) -> Result<Vec<SealedBlockWithSenders<Self::Block>>, 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<Self::Block>, ProviderError>
fn block_by_hash( &self, hash: FixedBytes<32>, ) -> Result<Option<Self::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<Self::Block>, ProviderError>
fn block_by_number( &self, num: u64, ) -> Result<Option<Self::Block>, ProviderError>
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.