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
sourceimpl BlockHeader
impl BlockHeader
sourcepub fn write_pre_pow<W: Writer>(&self, writer: &mut W) -> Result<(), Error>
pub fn write_pre_pow<W: Writer>(&self, writer: &mut W) -> Result<(), Error>
Write the pre-hash portion of the header
sourcepub fn pre_pow(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn pre_pow(&self) -> Vec<u8>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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
sourcepub fn from_pre_pow_and_proof(
pre_pow: String,
nonce: u64,
proof: Proof
) -> Result<Self, Error>
pub fn from_pre_pow_and_proof(
pre_pow: String,
nonce: u64,
proof: Proof
) -> Result<Self, Error>
Constructs a header given pre_pow string, nonce, and proof
sourcepub fn output_mmr_count(&self) -> u64
pub fn output_mmr_count(&self) -> u64
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.
sourcepub fn kernel_mmr_count(&self) -> u64
pub fn kernel_mmr_count(&self) -> u64
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.
sourcepub fn total_difficulty(&self) -> Difficulty
pub fn total_difficulty(&self) -> Difficulty
Total difficulty accumulated by the proof of work on this header
sourcepub fn overage(&self) -> i64
pub fn overage(&self) -> i64
The “overage” to use when verifying the kernel sums. For a block header the overage is 0 - reward.
sourcepub fn total_overage(&self, genesis_had_reward: bool) -> i64
pub fn total_overage(&self, genesis_had_reward: bool) -> i64
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).
sourcepub fn total_kernel_offset(&self) -> BlindingFactor
pub fn total_kernel_offset(&self) -> BlindingFactor
Total kernel offset for the chain state up to and including this block.
Trait Implementations
sourceimpl Clone for BlockHeader
impl Clone for BlockHeader
sourcefn clone(&self) -> BlockHeader
fn clone(&self) -> BlockHeader
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for BlockHeader
impl Debug for BlockHeader
sourceimpl Default for BlockHeader
impl Default for BlockHeader
sourcefn default() -> BlockHeader
fn default() -> BlockHeader
Returns the “default value” for a type. Read more
sourceimpl From<UntrustedBlockHeader> for BlockHeader
impl From<UntrustedBlockHeader> for BlockHeader
sourcefn from(header: UntrustedBlockHeader) -> Self
fn from(header: UntrustedBlockHeader) -> Self
Performs the conversion.
sourceimpl PMMRable for BlockHeader
impl PMMRable for BlockHeader
sourceimpl PartialEq<BlockHeader> for BlockHeader
impl PartialEq<BlockHeader> for BlockHeader
sourcefn eq(&self, other: &BlockHeader) -> bool
fn eq(&self, other: &BlockHeader) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &BlockHeader) -> bool
fn ne(&self, other: &BlockHeader) -> bool
This method tests for !=
.
sourceimpl Readable for BlockHeader
impl Readable for BlockHeader
Deserialization of a block header
sourceimpl Serialize for BlockHeader
impl Serialize for BlockHeader
sourceimpl Writeable for BlockHeader
impl Writeable for BlockHeader
Serialization of a block header
impl DefaultHashable for BlockHeader
impl StructuralPartialEq for BlockHeader
Auto Trait Implementations
impl RefUnwindSafe for BlockHeader
impl Send for BlockHeader
impl Sync for BlockHeader
impl Unpin for BlockHeader
impl UnwindSafe for BlockHeader
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> CloneAny for T where
T: Any + Clone,
impl<T> CloneAny for T where
T: Any + Clone,
fn clone_any(&self) -> Box<dyn CloneAny + 'static, Global>
fn clone_any_send(&self) -> Box<dyn CloneAny + Send + 'static, Global> where
T: Send,
fn clone_any_sync(&self) -> Box<dyn CloneAny + Sync + 'static, Global> where
T: Sync,
fn clone_any_send_sync(
&self
) -> Box<dyn CloneAny + Send + Sync + 'static, Global> where
T: Send + Sync,
sourceimpl<D> Hashed for D where
D: DefaultHashable,
impl<D> Hashed for D where
D: DefaultHashable,
sourceimpl<T> PMMRIndexHashable for T where
T: DefaultHashable,
impl<T> PMMRIndexHashable for T where
T: DefaultHashable,
sourcefn hash_with_index(&self, index: u64) -> Hash
fn hash_with_index(&self, index: u64) -> Hash
Hash with a given index
sourceimpl<H> ShortIdentifiable for H where
H: Hashed,
impl<H> ShortIdentifiable for H where
H: Hashed,
sourcefn short_id(&self, hash: &Hash, nonce: u64) -> ShortId
fn short_id(&self, hash: &Hash, nonce: u64) -> ShortId
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)
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more