Block in reth_node_api - Rust

Trait Block 

pub trait Block:
    Send
    + Sync
    + Unpin
    + Clone
    + Default
    + Debug
    + PartialEq
    + Eq
    + InMemorySize
    + MaybeSerde
    + Encodable
    + Decodable {
    type Header: BlockHeader;
    type Body: BlockBody<OmmerHeader = Self::Header>;

Show 17 methods // Required methods fn new(header: Self::Header, body: Self::Body) -> Self; fn header(&self) -> &Self::Header; fn body(&self) -> &Self::Body; fn split(self) -> (Self::Header, Self::Body); fn rlp_length(header: &Self::Header, body: &Self::Body) -> usize; // Provided methods fn new_sealed( header: SealedHeader<Self::Header>, body: Self::Body, ) -> SealedBlock<Self> { ... } fn seal_unchecked(self, hash: FixedBytes<32>) -> SealedBlock<Self> { ... } fn seal(self) -> SealedBlock<Self> { ... } fn seal_slow(self) -> SealedBlock<Self> { ... } fn split_ref(&self) -> (&Self::Header, &Self::Body) { ... } fn into_header(self) -> Self::Header { ... } fn into_body(self) -> Self::Body { ... } fn recover_signers(&self) -> Result<Vec<Address>, RecoveryError> where <Self::Body as BlockBody>::Transaction: SignedTransaction { ... } fn try_into_recovered_unchecked( self, senders: Vec<Address>, ) -> Result<RecoveredBlock<Self>, BlockRecoveryError<Self>> where <Self::Body as BlockBody>::Transaction: SignedTransaction { ... } fn into_recovered_with_signers( self, signers: Vec<Address>, ) -> RecoveredBlock<Self> where <Self::Body as BlockBody>::Transaction: SignedTransaction { ... } fn try_into_recovered( self, ) -> Result<RecoveredBlock<Self>, BlockRecoveryError<Self>> { ... } fn into_ethereum_block( self, ) -> Block<<Self::Body as BlockBody>::Transaction, Self::Header> { ... }
}
Expand description

Abstraction of block data type.

This type defines the structure of a block in the blockchain. A Block is composed of a header and a body. It is expected that a block can always be completely reconstructed from its header and body

Header part of the block.

The block’s body contains the transactions in the block and additional data, e.g. withdrawals in ethereum.

Create new block instance.

Returns reference to block header.

Returns reference to block body.

Splits the block into its header and body.

Returns the rlp length of the block with the given header and body.

Create new a sealed block instance from a sealed header and the block body.

Seal the block with a known hash.

WARNING: This method does not perform validation whether the hash is correct.

Creates the [SealedBlock] from the block’s parts without calculating the hash upfront.

Calculate the header hash and seal the block so that it can’t be changed.

Returns a tuple of references to the block’s header and body.

Consumes the block and returns the header.

Consumes the block and returns the body.

Expensive operation that recovers transaction signer.

Transform the block into a [RecoveredBlock] using the given senders.

If the number of senders does not match the number of transactions in the block, this falls back to manually recovery, but without ensuring that the signature has a low s value.

Returns the block as error if a signature is invalid.

Transform the block into a [RecoveredBlock] using the given signers.

Note: This method assumes the signers are correct and does not validate them.

Expensive. Transform into a [RecoveredBlock] by recovering senders in the contained transactions.

Returns the block as error if a signature is invalid.

A Convenience function to convert this type into the regular ethereum block that consists of:

  • Header

And the ethereum block body [alloy_consensus::BlockBody], see also BlockBody::into_ethereum_body.

  • Transactions
  • Withdrawals
  • Ommers

Note: This conversion can be incomplete. It is not expected that this Block is the same as [alloy_consensus::Block] only that it can be converted into it which is useful for the eth_ RPC namespace (e.g. RPC block).

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

§

§
§
§
§
§
§