pub struct BlockHeader {
    pub version: HeaderVersion,
    pub height: u64,
    pub prev_hash: Hash,
    pub prev_root: Hash,
    pub timestamp: DateTime<Utc>,
    pub output_root: Hash,
    pub range_proof_root: Hash,
    pub kernel_root: Hash,
    pub total_kernel_offset: BlindingFactor,
    pub output_mmr_size: u64,
    pub kernel_mmr_size: u64,
    pub pow: ProofOfWork,
}
Expand description

Block header, fairly standard compared to other blockchains.

Fields

version: HeaderVersion

Version of the block

height: u64

Height of this block since the genesis block (height 0)

prev_hash: Hash

Hash of the block previous to this in the chain.

prev_root: Hash

Root hash of the header MMR at the previous header.

timestamp: DateTime<Utc>

Timestamp at which the block was built.

output_root: Hash

Merklish root of all the commitments in the TxHashSet

range_proof_root: Hash

Merklish root of all range proofs in the TxHashSet

kernel_root: Hash

Merklish root of all transaction kernels in the TxHashSet

total_kernel_offset: BlindingFactor

Total accumulated sum of kernel offsets since genesis block. We can derive the kernel offset sum for this block from the total kernel offset of the previous block header.

output_mmr_size: u64

Total size of the output MMR after applying this block

kernel_mmr_size: u64

Total size of the kernel MMR after applying this block

pow: ProofOfWork

Proof of work and related

Implementations

Write the pre-hash portion of the header

Return the pre-pow, unhashed Let the cuck(at)oo miner/verifier handle the hashing for consistency with how this call is performed everywhere else

Constructs a header given pre_pow string, nonce, and proof

Total number of outputs (spent and unspent) based on output MMR size committed to in this block. Note: Not the number of outputs in this block but total up to and including this block. The MMR size is the total number of hashes contained in the full MMR structure. We want the corresponding number of leaves in the MMR given the size.

Total number of kernels based on kernel MMR size committed to in this block. Note: Not the number of kernels in this block but total up to and including this block. The MMR size is the total number of hashes contained in the full MMR structure. We want the corresponding number of leaves in the MMR given the size.

Total difficulty accumulated by the proof of work on this header

The “overage” to use when verifying the kernel sums. For a block header the overage is 0 - reward.

The “total overage” to use when verifying the kernel sums for a full chain state. For a full chain state this is 0 - (height * reward).

Total kernel offset for the chain state up to and including this block.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Performs the conversion.

The type of element actually stored in the MMR data file. This allows us to store Hash elements in the header MMR for variable size BlockHeaders. Read more

Convert the pmmrable into the element to be stored in the MMR data file.

Size of each element if “fixed” size. Elements are “variable” size if None.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Deserialization of a block header

Reads the data necessary to this Readable from the provided reader

Serialize this value into the given Serde serializer. Read more

Serialization of a block header

Write the data held by this Writeable to the provided writer

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Obtain the hash of the object

Calls U::from(self).

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

Hash with a given index

Should always be Self

Generate a short_id via the following -

  • extract k0/k1 from block_hash hashed with the nonce (first two u64 values) * initialize a siphasher24 with k0/k1
    • self.hash() passing in the siphasher24 instance
    • drop the 2 most significant bytes (to return a 6 byte short_id)

The resulting type after obtaining ownership.

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.