Struct BlockHeader

Source
pub struct BlockHeader {
Show 24 fields pub parent_hash: Vec<u8>, pub uncle_hash: Vec<u8>, pub coinbase: Vec<u8>, pub state_root: Vec<u8>, pub transactions_root: Vec<u8>, pub receipt_root: Vec<u8>, pub logs_bloom: Vec<u8>, pub difficulty: Option<BigInt>, pub total_difficulty: Option<BigInt>, pub number: u64, pub gas_limit: u64, pub gas_used: u64, pub timestamp: Option<Timestamp>, pub extra_data: Vec<u8>, pub mix_hash: Vec<u8>, pub nonce: u64, pub hash: Vec<u8>, pub base_fee_per_gas: Option<BigInt>, pub withdrawals_root: Vec<u8>, pub tx_dependency: Option<Uint64NestedArray>, pub blob_gas_used: Option<u64>, pub excess_blob_gas: Option<u64>, pub parent_beacon_root: Vec<u8>, pub requests_hash: Vec<u8>,
}

Fields§

§parent_hash: Vec<u8>§uncle_hash: Vec<u8>

Uncle hash of the block, some reference it as sha3Uncles, but sha3`` is badly worded, so we prefer uncle_hash, also referred as ommers` in EIP specification.

If the Block containing this BlockHeader has been produced using the Proof of Stake consensus algorithm, this field will actually be constant and set to 0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347.

§coinbase: Vec<u8>§state_root: Vec<u8>§transactions_root: Vec<u8>§receipt_root: Vec<u8>§logs_bloom: Vec<u8>§difficulty: Option<BigInt>

Difficulty is the difficulty of the Proof of Work algorithm that was required to compute a solution.

If the Block containing this BlockHeader has been produced using the Proof of Stake consensus algorithm, this field will actually be constant and set to 0x00.

§total_difficulty: Option<BigInt>
👎Deprecated

TotalDifficulty used to be the sum of all previous blocks difficulty including this block difficulty.

It has been deprecated in geth v1.15.0 but was already removed from the JSON-RPC interface for a while

§number: u64§gas_limit: u64§gas_used: u64§timestamp: Option<Timestamp>§extra_data: Vec<u8>

ExtraData is free-form bytes included in the block by the “miner”. While on Yellow paper of Ethereum this value is maxed to 32 bytes, other consensus algorithm like Clique and some other forks are using bigger values to carry special consensus data.

If the Block containing this BlockHeader has been produced using the Proof of Stake consensus algorithm, this field is strictly enforced to be <= 32 bytes.

§mix_hash: Vec<u8>

MixHash is used to prove, when combined with the nonce that sufficient amount of computation has been achieved and that the solution found is valid.

§nonce: u64

Nonce is used to prove, when combined with the mix_hash that sufficient amount of computation has been achieved and that the solution found is valid.

If the Block containing this BlockHeader has been produced using the Proof of Stake consensus algorithm, this field will actually be constant and set to 0.

§hash: Vec<u8>

Hash is the hash of the block which is actually the computation:

Keccak256(rlp([ parent_hash, uncle_hash, coinbase, state_root, transactions_root, receipt_root, logs_bloom, difficulty, number, gas_limit, gas_used, timestamp, extra_data, mix_hash, nonce, base_fee_per_gas (to be included only if London fork is active) withdrawals_root (to be included only if Shangai fork is active) blob_gas_used (to be included only if Cancun fork is active) excess_blob_gas (to be included only if Cancun fork is active) parent_beacon_root (to be included only if Cancun fork is active) requests_hash (to be included only if Prague fork is active) ]))

§base_fee_per_gas: Option<BigInt>

Base fee per gas according to EIP-1559 (e.g. London Fork) rules, only set if London is present/active on the chain.

§withdrawals_root: Vec<u8>

Withdrawals root hash according to EIP-4895 (e.g. Shangai Fork) rules, only set if Shangai is present/active on the chain.

Only available in DetailLevel: EXTENDED

§tx_dependency: Option<Uint64NestedArray>

TxDependency is list of transaction indexes that are dependent on each other in the block header. This is metadata only that was used by the internal Polygon parallel execution engine.

This field was available in a few versions on Polygon Mainnet and Polygon Mumbai chains. It was actually removed and is not populated anymore. It’s now embedded in the extraData field, refer to Polygon source code to determine how to extract it if you need it.

Only available in DetailLevel: EXTENDED

§blob_gas_used: Option<u64>

BlobGasUsed was added by EIP-4844 and is ignored in legacy headers.

§excess_blob_gas: Option<u64>

ExcessBlobGas was added by EIP-4844 and is ignored in legacy headers.

§parent_beacon_root: Vec<u8>

ParentBeaconRoot was added by EIP-4788 and is ignored in legacy headers.

§requests_hash: Vec<u8>

RequestsHash was added by EIP-7685 and is ignored in legacy headers.

Implementations§

Source§

impl BlockHeader

Source

pub fn blob_gas_used(&self) -> u64

Returns the value of blob_gas_used, or the default value if blob_gas_used is unset.

Source

pub fn excess_blob_gas(&self) -> u64

Returns the value of excess_blob_gas, or the default value if excess_blob_gas is unset.

Trait Implementations§

Source§

impl Clone for BlockHeader

Source§

fn clone(&self) -> BlockHeader

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 Debug for BlockHeader

Source§

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

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

impl Default for BlockHeader

Source§

fn default() -> BlockHeader

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

impl Message for BlockHeader

Source§

fn encoded_len(&self) -> usize

Returns the encoded length of the message without a length delimiter.
Source§

fn clear(&mut self)

Clears the message, resetting all fields to their default.
Source§

fn encode(&self, buf: &mut impl BufMut) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message to a buffer. Read more
Source§

fn encode_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message to a newly allocated buffer.
Source§

fn encode_length_delimited( &self, buf: &mut impl BufMut, ) -> Result<(), EncodeError>
where Self: Sized,

Encodes the message with a length-delimiter to a buffer. Read more
Source§

fn encode_length_delimited_to_vec(&self) -> Vec<u8>
where Self: Sized,

Encodes the message with a length-delimiter to a newly allocated buffer.
Source§

fn decode(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes an instance of the message from a buffer. Read more
Source§

fn decode_length_delimited(buf: impl Buf) -> Result<Self, DecodeError>
where Self: Default,

Decodes a length-delimited instance of the message from the buffer.
Source§

fn merge(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes an instance of the message from a buffer, and merges it into self. Read more
Source§

fn merge_length_delimited(&mut self, buf: impl Buf) -> Result<(), DecodeError>
where Self: Sized,

Decodes a length-delimited instance of the message from buffer, and merges it into self.
Source§

impl PartialEq for BlockHeader

Source§

fn eq(&self, other: &BlockHeader) -> 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 StructuralPartialEq for BlockHeader

Auto Trait Implementations§

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

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V