Struct Header
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 committing 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§
§impl Header
impl Header
pub const SIZE: usize = 80usize
pub const SIZE: usize = 80usize
The number of bytes that the block header contributes to the size of a block.
pub fn block_hash(&self) -> BlockHash
pub fn block_hash(&self) -> BlockHash
Returns the block hash.
pub 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.
pub fn difficulty(&self, params: impl AsRef<Params>) -> u128
pub fn difficulty(&self, params: impl AsRef<Params>) -> u128
Computes the popular “difficulty” measure for mining.
Difficulty represents how difficult the current target makes it to find a block, relative to how difficult it would be at the highest possible target (highest target == lowest difficulty).
pub 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.
pub 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§
§impl<'de> Deserialize<'de> for Header
impl<'de> Deserialize<'de> for Header
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Header, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Header, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Ord for Header
impl Ord for Header
§impl PartialOrd for Header
impl PartialOrd for Header
§impl Serialize for Header
impl Serialize for Header
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for Header
impl Eq for Header
impl StructuralPartialEq for Header
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnwindSafe for Header
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request