Trait BlockBody

Source
pub trait BlockBody:
    Send
    + Sync
    + Unpin
    + Clone
    + Default
    + Debug
    + PartialEq
    + Eq
    + Encodable
    + Decodable
    + InMemorySize
    + MaybeSerde
    + MaybeSerdeBincodeCompat
    + 'static {
    type Transaction: SignedTransaction;
    type OmmerHeader: BlockHeader;

    // Required methods
    fn transactions(&self) -> &[Self::Transaction];
    fn into_transactions(self) -> Vec<Self::Transaction>;
    fn withdrawals(&self) -> Option<&Withdrawals>;
    fn ommers(&self) -> Option<&[Self::OmmerHeader]>;

    // Provided methods
    fn calculate_tx_root(&self) -> B256 { ... }
    fn calculate_withdrawals_root(&self) -> Option<B256> { ... }
    fn calculate_ommers_root(&self) -> Option<B256> { ... }
    fn blob_gas_used(&self) -> u64 { ... }
    fn blob_versioned_hashes_iter(&self) -> impl Iterator<Item = &B256> + '_ { ... }
    fn encoded_2718_transactions_iter(
        &self,
    ) -> impl Iterator<Item = Vec<u8>> + '_ { ... }
    fn encoded_2718_transactions(&self) -> Vec<Bytes> { ... }
}
Expand description

Abstraction for block’s body.

Required Associated Types§

Source

type Transaction: SignedTransaction

Ordered list of signed transactions as committed in block.

Source

type OmmerHeader: BlockHeader

Ommer header type.

Required Methods§

Source

fn transactions(&self) -> &[Self::Transaction]

Returns reference to transactions in block.

Source

fn into_transactions(self) -> Vec<Self::Transaction>

Consume the block body and return a Vec of transactions.

Source

fn withdrawals(&self) -> Option<&Withdrawals>

Returns block withdrawals if any.

Source

fn ommers(&self) -> Option<&[Self::OmmerHeader]>

Returns block ommers if any.

Provided Methods§

Source

fn calculate_tx_root(&self) -> B256

Calculate the transaction root for the block body.

Source

fn calculate_withdrawals_root(&self) -> Option<B256>

Calculate the withdrawals root for the block body.

Returns None if there are no withdrawals in the block.

Source

fn calculate_ommers_root(&self) -> Option<B256>

Calculate the ommers root for the block body.

Returns None if there are no ommers in the block.

Source

fn blob_gas_used(&self) -> u64

Calculates the total blob gas used by all EIP-4844 transactions in the block.

Source

fn blob_versioned_hashes_iter(&self) -> impl Iterator<Item = &B256> + '_

Returns an iterator over all blob versioned hashes in the block body.

Source

fn encoded_2718_transactions_iter(&self) -> impl Iterator<Item = Vec<u8>> + '_

Returns an iterator over the encoded 2718 transactions.

This is also known as raw transactions.

See also [Encodable2718].

Source

fn encoded_2718_transactions(&self) -> Vec<Bytes>

Returns a vector of encoded 2718 transactions.

This is also known as raw transactions.

See also [Encodable2718].

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.

Implementors§