pub struct Header {
pub version: Version,
pub prev_blockhash: BlockHash,
pub merkle_root: TxMerkleNode,
pub time: u32,
pub bits: CompactTarget,
pub nonce: u32,
}
Expand description
Bitcoin block header.
Contains all the block’s information except the actual transactions, but including a root of a merkle tree commiting to all transactions in the block.
Bitcoin Core References
Fields§
§version: Version
Block version, now repurposed for soft fork signalling.
prev_blockhash: BlockHash
Reference to the previous block in the chain.
merkle_root: TxMerkleNode
The root hash of the merkle tree of transactions in the block.
time: u32
The timestamp of the block, as claimed by the miner.
bits: CompactTarget
The target value below which the blockhash must lie.
nonce: u32
The nonce, selected to obtain a low enough blockhash.
Implementations§
source§impl Header
impl Header
sourcepub const SIZE: usize = 80usize
pub const SIZE: usize = 80usize
The number of bytes that the block header contributes to the size of a block.
sourcepub fn block_hash(&self) -> BlockHash
pub fn block_hash(&self) -> BlockHash
Returns the block hash.
sourcepub fn target(&self) -> Target
pub fn target(&self) -> Target
Computes the target (range [0, T] inclusive) that a blockhash must land in to be valid.
sourcepub fn difficulty(&self) -> u128
pub fn difficulty(&self) -> u128
Computes the popular “difficulty” measure for mining.
sourcepub fn difficulty_float(&self) -> f64
pub fn difficulty_float(&self) -> f64
Computes the popular “difficulty” measure for mining and returns a float value of f64.
sourcepub fn validate_pow(
&self,
required_target: Target
) -> Result<BlockHash, ValidationError>
pub fn validate_pow( &self, required_target: Target ) -> Result<BlockHash, ValidationError>
Checks that the proof-of-work for the block is valid, returning the block hash.
Trait Implementations§
source§impl<'de> Deserialize<'de> for Header
impl<'de> Deserialize<'de> for Header
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,
source§impl Ord for Header
impl Ord for Header
source§impl PartialEq<Header> for Header
impl PartialEq<Header> for Header
source§impl PartialOrd<Header> for Header
impl PartialOrd<Header> for Header
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read more