Struct miden_objects::block::BlockHeader
source · pub struct BlockHeader { /* private fields */ }Expand description
The header of a block. It contains metadata about the block, commitments to the current state of the chain and the hash of the proof that attests to the integrity of the chain.
A block header includes the following fields:
versionspecifies the version of the protocol.prev_hashis the hash of the previous block header.block_numis a unique sequential number of the current block.chain_rootis a commitment to an MMR of the entire chain where each block is a leaf.account_rootis a commitment to account database.nullifier_rootis a commitment to the nullifier database.note_rootis a commitment to all notes created in the current block.batch_rootis a commitment to a set of transaction batches executed as a part of this block.proof_hashis a hash of a STARK proof attesting to the correct state transition.timestampis the time when the block was created, in seconds since UNIX epoch. Current representation is sufficient to represent time up to year 2106.sub_hashis a sequential hash of all fields except the note_root.hashis a 2-to-1 hash of the sub_hash and the note_root.
Implementations§
source§impl BlockHeader
impl BlockHeader
sourcepub fn new(
version: u32,
prev_hash: Digest,
block_num: u32,
chain_root: Digest,
account_root: Digest,
nullifier_root: Digest,
note_root: Digest,
batch_root: Digest,
proof_hash: Digest,
timestamp: u32
) -> Self
pub fn new( version: u32, prev_hash: Digest, block_num: u32, chain_root: Digest, account_root: Digest, nullifier_root: Digest, note_root: Digest, batch_root: Digest, proof_hash: Digest, timestamp: u32 ) -> Self
Creates a new block header.
sourcepub fn sub_hash(&self) -> Digest
pub fn sub_hash(&self) -> Digest
Returns the sub hash of the block header. The sub hash is a sequential hash of all block header fields except the note root. This is used in the block hash computation which is a 2-to-1 hash of the sub hash and the note root [hash(sub_hash, note_root)]. This procedure is used to make the note root easily accessible without having to unhash the entire header.
sourcepub fn chain_root(&self) -> Digest
pub fn chain_root(&self) -> Digest
Returns the chain root.
sourcepub fn account_root(&self) -> Digest
pub fn account_root(&self) -> Digest
Returns the account database root.
sourcepub fn nullifier_root(&self) -> Digest
pub fn nullifier_root(&self) -> Digest
Returns the nullifier database root.
sourcepub fn batch_root(&self) -> Digest
pub fn batch_root(&self) -> Digest
Returns the batch root.
sourcepub fn proof_hash(&self) -> Digest
pub fn proof_hash(&self) -> Digest
Returns the proof hash.
Trait Implementations§
source§impl Clone for BlockHeader
impl Clone for BlockHeader
source§fn clone(&self) -> BlockHeader
fn clone(&self) -> BlockHeader
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for BlockHeader
impl Debug for BlockHeader
source§impl Deserializable for BlockHeader
impl Deserializable for BlockHeader
source§fn read_from<R: ByteReader>(
source: &mut R
) -> Result<Self, DeserializationError>
fn read_from<R: ByteReader>( source: &mut R ) -> Result<Self, DeserializationError>
Reads a sequence of bytes from the provided
source, attempts to deserialize these bytes
into Self, and returns the result. Read moresource§fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
fn read_from_bytes(bytes: &[u8]) -> Result<Self, DeserializationError>
source§impl PartialEq for BlockHeader
impl PartialEq for BlockHeader
source§fn 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 ==.source§impl Serializable for BlockHeader
impl Serializable for BlockHeader
source§fn write_into<W: ByteWriter>(&self, target: &mut W)
fn write_into<W: ByteWriter>(&self, target: &mut W)
Serializes
self into bytes and writes these bytes into the target.source§fn get_size_hint(&self) -> usize
fn get_size_hint(&self) -> usize
Returns an estimate of how many bytes are needed to represent self. Read more
impl Copy for BlockHeader
impl Eq for BlockHeader
impl StructuralPartialEq for BlockHeader
Auto Trait Implementations§
impl Freeze for BlockHeader
impl RefUnwindSafe for BlockHeader
impl Send for BlockHeader
impl Sync for BlockHeader
impl Unpin for BlockHeader
impl UnwindSafe for BlockHeader
Blanket Implementations§
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
Mutably borrows from an owned value. Read more