Type Alias Block

pub type Block = Block<TransactionSigned>;
Expand description

Re-exported ethereum types Type alias for the ethereum block

Aliased Type§

struct Block {
    pub header: Header,
    pub body: BlockBody<TransactionSigned>,
}

Fields§

§header: Header

Block header.

§body: BlockBody<TransactionSigned>

Block body.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 792 bytes

Implementations

§

impl<T, H> Block<T, H>

pub const fn new(header: H, body: BlockBody<T, H>) -> Block<T, H>

Creates a new block with the given header and body.

pub fn uncle(header: H) -> Block<T, H>

Creates a new empty uncle block.

pub fn into_header(self) -> H

Consumes the block and returns the header.

pub fn into_body(self) -> BlockBody<T, H>

Consumes the block and returns the body.

pub fn map_header<U>(self, f: impl FnMut(H) -> U) -> Block<T, U>

Converts the block’s header type by applying a function to it.

pub fn try_map_header<U, E>( self, f: impl FnMut(H) -> Result<U, E>, ) -> Result<Block<T, U>, E>

Converts the block’s header type by applying a fallible function to it.

pub fn convert_transactions<U>(self) -> Block<U, H>
where U: From<T>,

Converts the block’s transaction type to the given alternative that is From<T>

pub fn try_convert_transactions<U>( self, ) -> Result<Block<U, H>, <U as TryFrom<T>>::Error>
where U: TryFrom<T>,

Converts the block’s transaction to the given alternative that is TryFrom<T>

Returns the block with the new transaction type if all conversions were successful.

pub fn map_transactions<U>(self, f: impl FnMut(T) -> U) -> Block<U, H>

Converts the block’s transaction type by applying a function to each transaction.

Returns the block with the new transaction type.

pub fn try_map_transactions<U, E>( self, f: impl FnMut(T) -> Result<U, E>, ) -> Result<Block<U, H>, E>

Converts the block’s transaction type by applying a fallible function to each transaction.

Returns the block with the new transaction type if all transactions were successfully.

pub fn rlp_length_for(header: &H, body: &BlockBody<T, H>) -> usize
where H: Encodable, T: Encodable,

Returns the RLP encoded length of the block’s header and body.

Trait Implementations

§

impl<'a, T, H> Arbitrary<'a> for Block<T, H>
where T: Arbitrary<'a>, H: Arbitrary<'a>,

Available on crate feature arbitrary only.
§

fn arbitrary(u: &mut Unstructured<'a>) -> Result<Block<T, H>, Error>

Generate an arbitrary value of Self from the given unstructured data. Read more
§

fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
§

fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
§

impl<T, H> Block for Block<T, H>

§

type Header = H

Header part of the block.
§

type Body = BlockBody<T, H>

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

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

Create new block instance.
§

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

Returns reference to block header.
§

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

Returns reference to block body.
§

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

Splits the block into its header and body.
§

fn rlp_length( header: &<Block<T, H> as Block>::Header, body: &<Block<T, H> as Block>::Body, ) -> usize

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

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_unchecked(self, hash: FixedBytes<32>) -> SealedBlock<Self>

Seal the block with a known hash. Read more
§

fn seal(self) -> SealedBlock<Self>

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

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 recover_signers(&self) -> Result<Vec<Address>, RecoveryError>

Expensive operation that recovers transaction signer.
§

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

Transform the block into a RecoveredBlock using the given senders. Read more
§

fn into_recovered_with_signers( self, signers: Vec<Address>, ) -> RecoveredBlock<Self>

Transform the block into a RecoveredBlock using the given signers. Read more
§

fn try_into_recovered( self, ) -> Result<RecoveredBlock<Self>, BlockRecoveryError<Self>>

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

impl<T, H> Clone for Block<T, H>
where T: Clone, H: Clone,

§

fn clone(&self) -> Block<T, H>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T, H> Debug for Block<T, H>
where T: Debug, H: Debug,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<T, H> Decodable for Block<T, H>
where T: Decodable, H: Decodable,

§

fn decode(b: &mut &[u8]) -> Result<Block<T, H>, Error>

Decodes the blob into the appropriate type. buf must be advanced past the decoded object.
§

impl<T, H> Default for Block<T, H>
where H: Default,

§

fn default() -> Block<T, H>

Returns the “default value” for a type. Read more
§

impl<T, H> Deref for Block<T, H>

§

type Target = H

The resulting type after dereferencing.
§

fn deref(&self) -> &<Block<T, H> as Deref>::Target

Dereferences the value.
§

impl<'de, T, H> Deserialize<'de> for Block<T, H>
where T: Deserialize<'de>, H: Deserialize<'de>,

§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Block<T, H>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl<T, H> Encodable for Block<T, H>
where T: Encodable, H: Encodable,

§

fn encode(&self, out: &mut dyn BufMut)

Encodes the type into the out buffer.
§

fn length(&self) -> usize

Returns the length of the encoding of this type in bytes. Read more
§

impl<T, H> EthBlock for Block<T, H>

§

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

Returns reference to withdrawals in the block if present
§

impl<'a, T, H> From<Block<'a, T, H>> for Block<T, H>

§

fn from(value: Block<'a, T, H>) -> Block<T, H>

Converts to this type from the input type.
§

impl<T, H> InMemorySize for Block<T, H>

§

fn size(&self) -> usize

Returns a heuristic for the in-memory size of a struct.
§

impl<T, H> PartialEq for Block<T, H>
where T: PartialEq, H: PartialEq,

§

fn eq(&self, other: &Block<T, H>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl<T, H> SerdeBincodeCompat for Block<T, H>

§

type BincodeRepr<'a> = Block<'a, T, H>

Serde representation of the type for bincode serialization. Read more
§

fn as_repr(&self) -> <Block<T, H> as SerdeBincodeCompat>::BincodeRepr<'_>

Convert this type into its bincode representation
§

fn from_repr( repr: <Block<T, H> as SerdeBincodeCompat>::BincodeRepr<'_>, ) -> Block<T, H>

Convert from the bincode representation
§

impl<T, H> Serialize for Block<T, H>
where T: Serialize, H: Serialize,

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
§

impl<T, H> TestBlock for Block<T, H>

Available on crate feature test-utils only.
§

fn body_mut(&mut self) -> &mut <Block<T, H> as Block>::Body

Returns mutable reference to block body.
§

fn header_mut(&mut self) -> &mut <Block<T, H> as Block>::Header

Returns mutable reference to block header.
§

fn set_header(&mut self, header: <Block<T, H> as Block>::Header)

Updates the block header.
§

fn set_parent_hash(&mut self, hash: FixedBytes<32>)

Updates the parent block hash.
§

fn set_block_number(&mut self, number: u64)

Updates the block number.
§

fn set_state_root(&mut self, state_root: FixedBytes<32>)

Updates the block state root.
§

fn set_difficulty(&mut self, difficulty: Uint<256, 4>)

Updates the block difficulty.
§

impl<T> TryFrom<ExecutionPayload> for Block<T>
where T: Decodable2718,

§

type Error = PayloadError

The type returned in the event of a conversion error.
§

fn try_from( value: ExecutionPayload, ) -> Result<Block<T>, <Block<T> as TryFrom<ExecutionPayload>>::Error>

Performs the conversion.
§

impl<T> TryFrom<ExecutionPayloadV1> for Block<T>
where T: Decodable2718,

§

type Error = PayloadError

The type returned in the event of a conversion error.
§

fn try_from( value: ExecutionPayloadV1, ) -> Result<Block<T>, <Block<T> as TryFrom<ExecutionPayloadV1>>::Error>

Performs the conversion.
§

impl<T> TryFrom<ExecutionPayloadV2> for Block<T>
where T: Decodable2718,

§

type Error = PayloadError

The type returned in the event of a conversion error.
§

fn try_from( value: ExecutionPayloadV2, ) -> Result<Block<T>, <Block<T> as TryFrom<ExecutionPayloadV2>>::Error>

Performs the conversion.
§

impl<T> TryFrom<ExecutionPayloadV3> for Block<T>
where T: Decodable2718,

§

type Error = PayloadError

The type returned in the event of a conversion error.
§

fn try_from( value: ExecutionPayloadV3, ) -> Result<Block<T>, <Block<T> as TryFrom<ExecutionPayloadV3>>::Error>

Performs the conversion.
§

impl<T, H> Eq for Block<T, H>
where T: Eq, H: Eq,

§

impl<T, H> StructuralPartialEq for Block<T, H>