Header

Struct Header 

Source
pub struct Header<H = Header> {
    pub hash: FixedBytes<32>,
    pub inner: H,
    pub total_difficulty: Option<Uint<256, 4>>,
    pub size: Option<Uint<256, 4>>,
}
Available on crate feature eth only.
Expand description

RPC representation of block header, wrapping a consensus header.

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

Fields§

§hash: FixedBytes<32>

Hash of the block

§inner: H

Inner consensus header.

§total_difficulty: Option<Uint<256, 4>>

Total difficulty

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

§size: Option<Uint<256, 4>>

Integer the size of this block in bytes.

Implementations§

Source§

impl<H> Header<H>

Source

pub fn new(inner: H) -> Header<H>
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>) -> Header<H>

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_sealed(self) -> Sealed<H>

Consumes the type and returns the Sealed header.

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<Uint<256, 4>>, size: Option<Uint<256, 4>>, ) -> Header<H>

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

Source

pub const fn with_total_difficulty( self, total_difficulty: Option<Uint<256, 4>>, ) -> Header<H>

Set the total difficulty of the block.

Source

pub const fn with_size(self, size: Option<Uint<256, 4>>) -> Header<H>

Set the size of the block.

Source

pub fn map<H1>(self, f: impl FnOnce(H) -> H1) -> Header<H1>

Applies the given closure to the inner header.

Source

pub fn try_map<H1, E>( self, f: impl FnOnce(H) -> Result<H1, E>, ) -> Result<Header<H1>, E>

Applies the given fallible closure to the inner header.

Source§

impl<H> Header<H>
where H: BlockHeader,

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<'arbitrary, H> Arbitrary<'arbitrary> for Header<H>
where H: Arbitrary<'arbitrary>,

Source§

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

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

fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Header<H>, Error>

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

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
Source§

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
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 for Header<H>
where H: BlockHeader,

Source§

fn parent_hash(&self) -> FixedBytes<32>

Retrieves the parent hash of the block
Source§

fn ommers_hash(&self) -> FixedBytes<32>

Retrieves the ommers hash of the block
Source§

fn beneficiary(&self) -> Address

Retrieves the beneficiary (miner) of the block
Source§

fn state_root(&self) -> FixedBytes<32>

Retrieves the state root hash of the block
Source§

fn transactions_root(&self) -> FixedBytes<32>

Retrieves the transactions root hash of the block
Source§

fn receipts_root(&self) -> FixedBytes<32>

Retrieves the receipts root hash of the block
Source§

fn withdrawals_root(&self) -> Option<FixedBytes<32>>

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) -> Uint<256, 4>

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<FixedBytes<32>>

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

fn nonce(&self) -> Option<FixedBytes<8>>

Retrieves the nonce of the block, if available
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<FixedBytes<32>>

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

fn requests_hash(&self) -> Option<FixedBytes<32>>

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

fn extra_data(&self) -> &Bytes

Retrieves the block’s extra data field
Source§

fn header_info(&self) -> HeaderInfo

Extracts essential information into one container type.
Source§

fn header_roots(&self) -> HeaderRoots

Returns all roots contained in the header.
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 maybe_next_block_excess_blob_gas( &self, blob_params: Option<BlobParams>, ) -> Option<u64>

Convenience function for Self::next_block_excess_blob_gas with an optional BlobParams argument. 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 maybe_next_block_blob_fee( &self, blob_params: Option<BlobParams>, ) -> Option<u128>

Convenience function for Self::next_block_blob_fee with an optional BlobParams argument. 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 for Header<H>
where H: Clone,

Source§

fn clone(&self) -> Header<H>

Returns a duplicate 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 for Header<H>
where H: Debug,

Source§

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

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

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

Source§

fn default() -> Header<H>

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

impl<H> Deref for Header<H>

Source§

type Target = H

The resulting type after dereferencing.
Source§

fn deref(&self) -> &<Header<H> as Deref>::Target

Dereferences the value.
Source§

impl<H> DerefMut for Header<H>

Source§

fn deref_mut(&mut self) -> &mut <Header<H> as Deref>::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<Header<H>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

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

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

Source§

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

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> HeaderResponse for Header<H>
where H: BlockHeader,

Source§

fn hash(&self) -> FixedBytes<32>

Block hash
Source§

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

Source§

fn eq(&self, other: &Header<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.
Source§

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

Source§

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
Source§

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

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§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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

Checks if this value is equivalent to the given key. Read more
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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<R> Rng for R
where R: RngCore + ?Sized,

Source§

fn random<T>(&mut self) -> T

Return a random value via the StandardUniform distribution. Read more
Source§

fn random_iter<T>(self) -> Iter<StandardUniform, Self, T>

Return an iterator over random variates Read more
Source§

fn random_range<T, R>(&mut self, range: R) -> T
where T: SampleUniform, R: SampleRange<T>,

Generate a random value in the given range. Read more
Source§

fn random_bool(&mut self, p: f64) -> bool

Return a bool with a probability p of being true. Read more
Source§

fn random_ratio(&mut self, numerator: u32, denominator: u32) -> bool

Return a bool with a probability of numerator/denominator of being true. Read more
Source§

fn sample<T, D>(&mut self, distr: D) -> T
where D: Distribution<T>,

Sample a new value, using the given distribution. Read more
Source§

fn sample_iter<T, D>(self, distr: D) -> Iter<D, Self, T>
where D: Distribution<T>, Self: Sized,

Create an iterator that generates values using the given distribution. Read more
Source§

fn fill<T>(&mut self, dest: &mut T)
where T: Fill + ?Sized,

Fill any type implementing Fill with random data Read more
Source§

fn gen<T>(&mut self) -> T

👎Deprecated since 0.9.0: Renamed to random to avoid conflict with the new gen keyword in Rust 2024.
Alias for Rng::random.
Source§

fn gen_range<T, R>(&mut self, range: R) -> T
where T: SampleUniform, R: SampleRange<T>,

👎Deprecated since 0.9.0: Renamed to random_range
Source§

fn gen_bool(&mut self, p: f64) -> bool

👎Deprecated since 0.9.0: Renamed to random_bool
Alias for Rng::random_bool.
Source§

fn gen_ratio(&mut self, numerator: u32, denominator: u32) -> bool

👎Deprecated since 0.9.0: Renamed to random_ratio
Source§

impl<T> RngCore for T
where T: DerefMut, <T as Deref>::Target: RngCore,

Source§

fn next_u32(&mut self) -> u32

Return the next random u32. Read more
Source§

fn next_u64(&mut self) -> u64

Return the next random u64. Read more
Source§

fn fill_bytes(&mut self, dst: &mut [u8])

Fill dest with random data. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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>,

Source§

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>,

Source§

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<R> TryRngCore for R
where R: RngCore + ?Sized,

Source§

type Error = Infallible

The type returned in the event of a RNG error.
Source§

fn try_next_u32(&mut self) -> Result<u32, <R as TryRngCore>::Error>

Return the next random u32.
Source§

fn try_next_u64(&mut self) -> Result<u64, <R as TryRngCore>::Error>

Return the next random u64.
Source§

fn try_fill_bytes( &mut self, dst: &mut [u8], ) -> Result<(), <R as TryRngCore>::Error>

Fill dest entirely with random data.
Source§

fn unwrap_err(self) -> UnwrapErr<Self>
where Self: Sized,

Wrap RNG with the UnwrapErr wrapper.
Source§

fn unwrap_mut(&mut self) -> UnwrapMut<'_, Self>

Wrap RNG with the UnwrapMut wrapper.
Source§

fn read_adapter(&mut self) -> RngReadAdapter<'_, Self>
where Self: Sized,

Available on crate feature std only.
Convert an RngCore to a RngReadAdapter.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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> CryptoRng for T
where T: DerefMut, <T as Deref>::Target: CryptoRng,

Source§

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

Source§

impl<T> Formattable for T
where T: Deref, <T as Deref>::Target: Formattable,

Source§

impl<T> Parsable for T
where T: Deref, <T as Deref>::Target: Parsable,

Source§

impl<R> TryCryptoRng for R
where R: CryptoRng + ?Sized,

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.