Struct alloy_rpc_types_eth::Header

source ·
pub struct Header<H = Header> {
    pub hash: BlockHash,
    pub inner: H,
    pub total_difficulty: Option<U256>,
    pub size: Option<U256>,
}
Expand description

RPC representation of block header, wrapping a consensus header.

This wraps the consensus header and adds additional fields for RPC.

Fields§

§hash: BlockHash

Hash of the block

§inner: H

Inner consensus header.

§total_difficulty: Option<U256>

Total difficulty

Note: This field is now effectively deprecated: https://github.com/ethereum/execution-apis/pull/570

§size: Option<U256>

Integer the size of this block in bytes.

Implementations§

source§

impl<H> Header<H>

source

pub fn new(inner: H) -> Self
where H: Sealable,

Create a new Header from a consensus header.

Note: This will compute the hash of the header.

source

pub fn from_sealed(header: Sealed<H>) -> Self

Create a new Header from a sealed consensus header.

Note: This does not set the total difficulty or size of the block.

source

pub fn into_consensus(self) -> H

Consumes the type and returns the wrapped consensus header.

source

pub fn from_consensus( header: Sealed<H>, total_difficulty: Option<U256>, size: Option<U256>, ) -> Self

Create a new Header from a sealed consensus header and additional fields.

source

pub const fn with_total_difficulty(self, total_difficulty: Option<U256>) -> Self

Set the total difficulty of the block.

source

pub const fn with_size(self, size: Option<U256>) -> Self

Set the size of the block.

source§

impl<H: BlockHeader> Header<H>

source

pub fn blob_fee(&self) -> Option<u128>

Returns the blob fee for this block according to the EIP-4844 spec.

Returns None if excess_blob_gas is None

source

pub fn next_block_blob_fee(&self, blob_params: BlobParams) -> Option<u128>

Returns the blob fee for the next block according to the EIP-4844 spec.

Returns None if excess_blob_gas is None.

See also Self::next_block_excess_blob_gas

source

pub fn next_block_excess_blob_gas(&self, blob_params: BlobParams) -> Option<u64>

Calculate excess blob gas for the next block according to the EIP-4844 spec.

Returns a None if no excess blob gas is set, no EIP-4844 support

Trait Implementations§

source§

impl<H> AsRef<H> for Header<H>

source§

fn as_ref(&self) -> &H

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<H: BlockHeader> BlockHeader for Header<H>

source§

fn parent_hash(&self) -> B256

Retrieves the parent hash of the block
source§

fn ommers_hash(&self) -> B256

Retrieves the ommers hash of the block
source§

fn beneficiary(&self) -> Address

Retrieves the beneficiary (miner) of the block
source§

fn state_root(&self) -> B256

Retrieves the state root hash of the block
source§

fn transactions_root(&self) -> B256

Retrieves the transactions root hash of the block
source§

fn receipts_root(&self) -> B256

Retrieves the receipts root hash of the block
source§

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

Retrieves the withdrawals root hash of the block, if available
source§

fn logs_bloom(&self) -> Bloom

Retrieves the logs bloom filter of the block
source§

fn difficulty(&self) -> U256

Retrieves the difficulty of the block
source§

fn number(&self) -> u64

Retrieves the block number
source§

fn gas_limit(&self) -> u64

Retrieves the gas limit of the block
source§

fn gas_used(&self) -> u64

Retrieves the gas used by the block
source§

fn timestamp(&self) -> u64

Retrieves the timestamp of the block
source§

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

Retrieves the mix hash of the block, if available
source§

fn nonce(&self) -> Option<B64>

Retrieves the nonce of the block, if avaialble
source§

fn base_fee_per_gas(&self) -> Option<u64>

Retrieves the base fee per gas of the block, if available
source§

fn blob_gas_used(&self) -> Option<u64>

Retrieves the blob gas used by the block, if available
source§

fn excess_blob_gas(&self) -> Option<u64>

Retrieves the excess blob gas of the block, if available
source§

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

Retrieves the parent beacon block root of the block, if available
source§

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

Retrieves the requests hash of the block, if available
source§

fn extra_data(&self) -> &Bytes

Retrieves the block’s extra data field
source§

fn blob_fee(&self, blob_params: BlobParams) -> Option<u128>

Returns the blob fee for this block according to the EIP-4844 spec. Read more
source§

fn next_block_excess_blob_gas(&self, blob_params: BlobParams) -> Option<u64>

Calculate excess blob gas for the next block according to the EIP-4844 spec. Read more
source§

fn next_block_blob_fee(&self, blob_params: BlobParams) -> Option<u128>

Returns the blob fee for the next block according to the EIP-4844 spec. Read more
source§

fn next_block_base_fee(&self, base_fee_params: BaseFeeParams) -> Option<u64>

Calculate base fee for next block according to the EIP-1559 spec. Read more
source§

fn parent_num_hash(&self) -> NumHash

Returns the parent block’s number and hash Read more
source§

fn is_empty(&self) -> bool

Checks if the header is considered empty - has no transactions, no ommers or withdrawals
source§

fn is_zero_difficulty(&self) -> bool

Checks if the block’s difficulty is set to zero, indicating a Proof-of-Stake header. Read more
source§

fn exceeds_allowed_future_timestamp(&self, present_timestamp: u64) -> bool

Checks if the block’s timestamp is in the future based on the present timestamp. Read more
source§

fn is_nonce_zero(&self) -> bool

Checks if the nonce exists, and if it exists, if it’s zero. Read more
source§

impl<H: Clone> Clone for Header<H>

source§

fn clone(&self) -> Header<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
source§

impl<H: Debug> Debug for Header<H>

source§

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

Formats the value using the given formatter. Read more
source§

impl<H: Default> Default for Header<H>

source§

fn default() -> Header<H>

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

impl<H> Deref for Header<H>

§

type Target = H

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl<H> DerefMut for Header<H>

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl<'de, H> Deserialize<'de> for Header<H>
where H: Deserialize<'de>,

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

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

impl From<Header> for Header

source§

fn from(header: Header) -> Self

Converts to this type from the input type.
source§

impl From<Header> for WithOtherFields<Header>

source§

fn from(inner: Header) -> Self

Converts to this type from the input type.
source§

impl<H: Hash> Hash for Header<H>

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<H: BlockHeader> HeaderResponse for Header<H>

source§

fn hash(&self) -> BlockHash

Block hash
source§

impl<H: PartialEq> PartialEq for Header<H>

source§

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

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

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

impl<H> Serialize for Header<H>
where H: Serialize,

source§

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

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

impl<H: Eq> Eq for Header<H>

source§

impl<H> StructuralPartialEq for Header<H>

Auto Trait Implementations§

§

impl<H> Freeze for Header<H>
where H: Freeze,

§

impl<H> RefUnwindSafe for Header<H>
where H: RefUnwindSafe,

§

impl<H> Send for Header<H>
where H: Send,

§

impl<H> Sync for Header<H>
where H: Sync,

§

impl<H> Unpin for Header<H>
where H: Unpin,

§

impl<H> UnwindSafe for Header<H>
where H: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

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

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

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

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

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,