Trait BlockReaderIdExt
pub trait BlockReaderIdExt: BlockReader + ReceiptProviderIdExt {
Show 13 methods
// Required methods
fn block_by_id(&self, id: BlockId) -> Result<Option<Block>, ProviderError>;
fn sealed_header_by_id(
&self,
id: BlockId,
) -> Result<Option<SealedHeader>, ProviderError>;
fn header_by_id(&self, id: BlockId) -> Result<Option<Header>, ProviderError>;
fn ommers_by_id(
&self,
id: BlockId,
) -> Result<Option<Vec<Header>>, ProviderError>;
// Provided methods
fn block_by_number_or_tag(
&self,
id: BlockNumberOrTag,
) -> Result<Option<Block>, ProviderError> { ... }
fn pending_header(&self) -> Result<Option<SealedHeader>, ProviderError> { ... }
fn latest_header(&self) -> Result<Option<SealedHeader>, ProviderError> { ... }
fn safe_header(&self) -> Result<Option<SealedHeader>, ProviderError> { ... }
fn finalized_header(&self) -> Result<Option<SealedHeader>, ProviderError> { ... }
fn block_with_senders_by_id(
&self,
id: BlockId,
transaction_kind: TransactionVariant,
) -> Result<Option<BlockWithSenders>, ProviderError> { ... }
fn header_by_number_or_tag(
&self,
id: BlockNumberOrTag,
) -> Result<Option<Header>, ProviderError> { ... }
fn sealed_header_by_number_or_tag(
&self,
id: BlockNumberOrTag,
) -> Result<Option<SealedHeader>, ProviderError> { ... }
fn ommers_by_number_or_tag(
&self,
id: BlockNumberOrTag,
) -> Result<Option<Vec<Header>>, ProviderError> { ... }
}
Expand description
Trait extension for BlockReader
, for types that implement BlockId
conversion.
The BlockReader
trait should be implemented on types that can retrieve a block from either
a block number or hash. However, it might be desirable to fetch a block from a BlockId
type,
which can be a number, hash, or tag such as BlockNumberOrTag::Safe
.
Resolving tags requires keeping track of block hashes or block numbers associated with the tag,
so this trait can only be implemented for types that implement BlockIdReader
. The
BlockIdReader
methods should be used to resolve BlockId
s to block numbers or hashes, and
retrieving the block should be done using the type’s BlockReader
methods.
Required Methods§
fn block_by_id(&self, id: BlockId) -> Result<Option<Block>, ProviderError>
fn block_by_id(&self, id: BlockId) -> Result<Option<Block>, ProviderError>
Returns the block with the matching [BlockId
] from the database.
Returns None
if block is not found.
fn sealed_header_by_id(
&self,
id: BlockId,
) -> Result<Option<SealedHeader>, ProviderError>
fn sealed_header_by_id( &self, id: BlockId, ) -> Result<Option<SealedHeader>, ProviderError>
Returns the sealed header with the matching BlockId
from the database.
Returns None
if header is not found.
fn header_by_id(&self, id: BlockId) -> Result<Option<Header>, ProviderError>
fn header_by_id(&self, id: BlockId) -> Result<Option<Header>, ProviderError>
Returns the header with the matching BlockId
from the database.
Returns None
if header is not found.
fn ommers_by_id(
&self,
id: BlockId,
) -> Result<Option<Vec<Header>>, ProviderError>
fn ommers_by_id( &self, id: BlockId, ) -> Result<Option<Vec<Header>>, ProviderError>
Returns the ommers with the matching BlockId
from the database.
Returns None
if block is not found.
Provided Methods§
fn block_by_number_or_tag(
&self,
id: BlockNumberOrTag,
) -> Result<Option<Block>, ProviderError>
fn block_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Block>, ProviderError>
Returns the block with matching tag from the database
Returns None
if block is not found.
fn pending_header(&self) -> Result<Option<SealedHeader>, ProviderError>
fn pending_header(&self) -> Result<Option<SealedHeader>, ProviderError>
Returns the pending block header if available
Note: This returns a SealedHeader
because it’s expected that this is sealed by the
provider and the caller does not know the hash.
fn latest_header(&self) -> Result<Option<SealedHeader>, ProviderError>
fn latest_header(&self) -> Result<Option<SealedHeader>, ProviderError>
Returns the latest block header if available
Note: This returns a SealedHeader
because it’s expected that this is sealed by the
provider and the caller does not know the hash.
fn safe_header(&self) -> Result<Option<SealedHeader>, ProviderError>
fn safe_header(&self) -> Result<Option<SealedHeader>, ProviderError>
Returns the safe block header if available
Note: This returns a SealedHeader
because it’s expected that this is sealed by the
provider and the caller does not know the hash.
fn finalized_header(&self) -> Result<Option<SealedHeader>, ProviderError>
fn finalized_header(&self) -> Result<Option<SealedHeader>, ProviderError>
Returns the finalized block header if available
Note: This returns a SealedHeader
because it’s expected that this is sealed by the
provider and the caller does not know the hash.
fn block_with_senders_by_id(
&self,
id: BlockId,
transaction_kind: TransactionVariant,
) -> Result<Option<BlockWithSenders>, ProviderError>
fn block_with_senders_by_id( &self, id: BlockId, transaction_kind: TransactionVariant, ) -> Result<Option<BlockWithSenders>, ProviderError>
Returns the block with senders with matching [BlockId
].
Returns the block’s transactions in the requested variant.
Returns None
if block is not found.
fn header_by_number_or_tag(
&self,
id: BlockNumberOrTag,
) -> Result<Option<Header>, ProviderError>
fn header_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Header>, ProviderError>
Returns the header with matching tag from the database
Returns None
if header is not found.
fn sealed_header_by_number_or_tag(
&self,
id: BlockNumberOrTag,
) -> Result<Option<SealedHeader>, ProviderError>
fn sealed_header_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<SealedHeader>, ProviderError>
Returns the header with matching tag from the database
Returns None
if header is not found.
fn ommers_by_number_or_tag(
&self,
id: BlockNumberOrTag,
) -> Result<Option<Vec<Header>>, ProviderError>
fn ommers_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Vec<Header>>, ProviderError>
Returns the ommers with the matching tag from the database.
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.
Implementations on Foreign Types§
§impl<'a, T> BlockReaderIdExt for &'a T
impl<'a, T> BlockReaderIdExt for &'a T
fn block_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Block>, ProviderError>
fn pending_header(&self) -> Result<Option<SealedHeader>, ProviderError>
fn latest_header(&self) -> Result<Option<SealedHeader>, ProviderError>
fn safe_header(&self) -> Result<Option<SealedHeader>, ProviderError>
fn finalized_header(&self) -> Result<Option<SealedHeader>, ProviderError>
fn block_by_id(&self, id: BlockId) -> Result<Option<Block>, ProviderError>
fn block_with_senders_by_id( &self, id: BlockId, transaction_kind: TransactionVariant, ) -> Result<Option<BlockWithSenders>, ProviderError>
fn header_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Header>, ProviderError>
fn sealed_header_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<SealedHeader>, ProviderError>
fn sealed_header_by_id( &self, id: BlockId, ) -> Result<Option<SealedHeader>, ProviderError>
fn header_by_id(&self, id: BlockId) -> Result<Option<Header>, ProviderError>
fn ommers_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Vec<Header>>, ProviderError>
fn ommers_by_id( &self, id: BlockId, ) -> Result<Option<Vec<Header>>, ProviderError>
§impl<T> BlockReaderIdExt for Arc<T>
impl<T> BlockReaderIdExt for Arc<T>
fn block_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Block>, ProviderError>
fn pending_header(&self) -> Result<Option<SealedHeader>, ProviderError>
fn latest_header(&self) -> Result<Option<SealedHeader>, ProviderError>
fn safe_header(&self) -> Result<Option<SealedHeader>, ProviderError>
fn finalized_header(&self) -> Result<Option<SealedHeader>, ProviderError>
fn block_by_id(&self, id: BlockId) -> Result<Option<Block>, ProviderError>
fn block_with_senders_by_id( &self, id: BlockId, transaction_kind: TransactionVariant, ) -> Result<Option<BlockWithSenders>, ProviderError>
fn header_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Header>, ProviderError>
fn sealed_header_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<SealedHeader>, ProviderError>
fn sealed_header_by_id( &self, id: BlockId, ) -> Result<Option<SealedHeader>, ProviderError>
fn header_by_id(&self, id: BlockId) -> Result<Option<Header>, ProviderError>
fn ommers_by_number_or_tag( &self, id: BlockNumberOrTag, ) -> Result<Option<Vec<Header>>, ProviderError>
fn ommers_by_id( &self, id: BlockId, ) -> Result<Option<Vec<Header>>, ProviderError>
Implementors§
impl BlockReaderIdExt for MockEthProvider
test-utils
only.impl BlockReaderIdExt for NoopProvider
test-utils
only.