reth::builder

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 15 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); // Provided methods fn new_sealed( header: SealedHeader<Self::Header>, body: Self::Body, ) -> SealedBlock<Self> { ... } fn seal(self, hash: FixedBytes<32>) -> 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 rlp_length(header: &Self::Header, body: &Self::Body) -> usize { ... } fn senders(&self) -> Option<Vec<Address>> where <Self::Body as BlockBody>::Transaction: SignedTransaction { ... } fn with_senders_unchecked( self, senders: Vec<Address>, ) -> RecoveredBlock<Self> where <Self::Body as BlockBody>::Transaction: SignedTransaction { ... } fn try_with_senders_unchecked( self, senders: Vec<Address>, ) -> Result<RecoveredBlock<Self>, Self> where <Self::Body as BlockBody>::Transaction: SignedTransaction { ... } fn with_recovered_senders(self) -> Option<RecoveredBlock<Self>> where <Self::Body as BlockBody>::Transaction: SignedTransaction { ... }
}
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.

Required Associated Types§

type Header: BlockHeader

Header part of the block.

type Body: BlockBody<OmmerHeader = Self::Header>

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

Required Methods§

fn new(header: Self::Header, body: Self::Body) -> Self

Create new block instance.

fn header(&self) -> &Self::Header

Returns reference to block header.

fn body(&self) -> &Self::Body

Returns reference to block body.

fn split(self) -> (Self::Header, Self::Body)

Splits the block into its header and body.

Provided Methods§

fn new_sealed( header: SealedHeader<Self::Header>, body: Self::Body, ) -> SealedBlock<Self>

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

fn seal(self, hash: FixedBytes<32>) -> SealedBlock<Self>

Seal the block with a known hash.

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

fn seal_slow(self) -> SealedBlock<Self>

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

fn split_ref(&self) -> (&Self::Header, &Self::Body)

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

fn into_header(self) -> Self::Header

Consumes the block and returns the header.

fn into_body(self) -> Self::Body

Consumes the block and returns the body.

fn rlp_length(header: &Self::Header, body: &Self::Body) -> usize

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

fn senders(&self) -> Option<Vec<Address>>

Expensive operation that recovers transaction signer.

fn with_senders_unchecked(self, senders: Vec<Address>) -> RecoveredBlock<Self>

Transform into a RecoveredBlock.

§Panics

If the number of senders does not match the number of transactions in the block and the signer recovery for one of the transactions fails.

Note: this is expected to be called with blocks read from disk.

fn try_with_senders_unchecked( self, senders: Vec<Address>, ) -> Result<RecoveredBlock<Self>, Self>

Transform 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 an error if a signature is invalid.

fn with_recovered_senders(self) -> Option<RecoveredBlock<Self>>

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

Returns None if a transaction is invalid.

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<T> Block for Block<T>

§

type Header = Header

§

type Body = BlockBody<T>

§

fn new( header: <Block<T> as Block>::Header, body: <Block<T> as Block>::Body, ) -> Block<T>

§

fn header(&self) -> &<Block<T> as Block>::Header

§

fn body(&self) -> &<Block<T> as Block>::Body

§

fn split(self) -> (<Block<T> as Block>::Header, <Block<T> as Block>::Body)

Implementors§