pub struct BlockHeader {
pub parent_hash: Hash,
pub height: BlockHeight,
pub timestamp: Timestamp,
pub tx_root: Hash,
pub state_root: Hash,
pub proposer_pubkey: [u8; 32],
pub proposer_sig: [u8; 64],
}Expand description
Block header containing metadata and proposer signature
Fields§
§parent_hash: HashHash of the parent block (zero for genesis)
height: BlockHeightBlock height (0 for genesis)
timestamp: TimestampBlock creation timestamp (ms since epoch)
tx_root: HashMerkle root of transactions
state_root: HashRoot hash of state after applying this block
proposer_pubkey: [u8; 32]Proposer’s Ed25519 public key
proposer_sig: [u8; 64]Proposer’s signature over the header hash (excluding this field)
Implementations§
Source§impl BlockHeader
impl BlockHeader
Sourcepub fn new(
parent_hash: Hash,
height: BlockHeight,
timestamp: Timestamp,
tx_root: Hash,
state_root: Hash,
proposer_pubkey: [u8; 32],
) -> Self
pub fn new( parent_hash: Hash, height: BlockHeight, timestamp: Timestamp, tx_root: Hash, state_root: Hash, proposer_pubkey: [u8; 32], ) -> Self
Create a new block header (signature must be added separately)
Sourcepub fn signing_hash(&self) -> Hash
pub fn signing_hash(&self) -> Hash
Compute the hash that the proposer signs This excludes the signature field itself to avoid circular dependency
Sourcepub fn hash(&self) -> Hash
pub fn hash(&self) -> Hash
Compute the full block header hash (includes signature) This is the hash used to reference the block
Sourcepub fn is_genesis(&self) -> bool
pub fn is_genesis(&self) -> bool
Check if this is a genesis block
Sourcepub fn set_signature(&mut self, signature: [u8; 64])
pub fn set_signature(&mut self, signature: [u8; 64])
Set the proposer signature
Trait Implementations§
Source§impl Clone for BlockHeader
impl Clone for BlockHeader
Source§fn clone(&self) -> BlockHeader
fn clone(&self) -> BlockHeader
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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<'de> Deserialize<'de> for BlockHeader
impl<'de> Deserialize<'de> for BlockHeader
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>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for BlockHeader
impl PartialEq for BlockHeader
Source§fn eq(&self, other: &BlockHeader) -> bool
fn eq(&self, other: &BlockHeader) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for BlockHeader
impl Serialize 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 UnsafeUnpin 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