Struct snarkvm_ledger_block::header::Header
source · pub struct Header<N: Network> { /* private fields */ }
Expand description
The header for the block contains metadata that uniquely identifies the block.
Implementations§
source§impl<N: Network> Header<N>
impl<N: Network> Header<N>
sourcepub fn genesis(
ratifications: &Ratifications<N>,
transactions: &Transactions<N>,
ratified_finalize_operations: Vec<FinalizeOperation<N>>
) -> Result<Self>
pub fn genesis( ratifications: &Ratifications<N>, transactions: &Transactions<N>, ratified_finalize_operations: Vec<FinalizeOperation<N>> ) -> Result<Self>
Initializes the genesis block header.
sourcepub fn is_genesis(&self) -> bool
pub fn is_genesis(&self) -> bool
Returns true
if the block header is a genesis block header.
source§impl<N: Network> Header<N>
impl<N: Network> Header<N>
source§impl<N: Network> Header<N>
impl<N: Network> Header<N>
sourcepub fn verify(
&self,
expected_previous_state_root: N::StateRoot,
expected_transactions_root: Field<N>,
expected_finalize_root: Field<N>,
expected_ratifications_root: Field<N>,
expected_solutions_root: Field<N>,
expected_subdag_root: Field<N>,
expected_round: u64,
expected_height: u32,
expected_cumulative_weight: u128,
expected_cumulative_proof_target: u128,
expected_coinbase_target: u64,
expected_proof_target: u64,
expected_last_coinbase_target: u64,
expected_last_coinbase_timestamp: i64,
expected_timestamp: i64,
current_timestamp: i64
) -> Result<()>
pub fn verify( &self, expected_previous_state_root: N::StateRoot, expected_transactions_root: Field<N>, expected_finalize_root: Field<N>, expected_ratifications_root: Field<N>, expected_solutions_root: Field<N>, expected_subdag_root: Field<N>, expected_round: u64, expected_height: u32, expected_cumulative_weight: u128, expected_cumulative_proof_target: u128, expected_coinbase_target: u64, expected_proof_target: u64, expected_last_coinbase_target: u64, expected_last_coinbase_timestamp: i64, expected_timestamp: i64, current_timestamp: i64 ) -> Result<()>
Ensures the block header is correct.
source§impl<N: Network> Header<N>
impl<N: Network> Header<N>
sourcepub fn from(
previous_state_root: N::StateRoot,
transactions_root: Field<N>,
finalize_root: Field<N>,
ratifications_root: Field<N>,
solutions_root: Field<N>,
subdag_root: Field<N>,
metadata: Metadata<N>
) -> Result<Self>
pub fn from( previous_state_root: N::StateRoot, transactions_root: Field<N>, finalize_root: Field<N>, ratifications_root: Field<N>, solutions_root: Field<N>, subdag_root: Field<N>, metadata: Metadata<N> ) -> Result<Self>
Initializes a new block header with the given inputs.
sourcepub const fn previous_state_root(&self) -> N::StateRoot
pub const fn previous_state_root(&self) -> N::StateRoot
Returns the previous state root from the block header.
sourcepub const fn transactions_root(&self) -> Field<N>
pub const fn transactions_root(&self) -> Field<N>
Returns the transactions root in the block header.
sourcepub const fn finalize_root(&self) -> Field<N>
pub const fn finalize_root(&self) -> Field<N>
Returns the finalize root in the block header.
sourcepub const fn ratifications_root(&self) -> Field<N>
pub const fn ratifications_root(&self) -> Field<N>
Returns the ratifications root in the block header.
sourcepub const fn solutions_root(&self) -> Field<N>
pub const fn solutions_root(&self) -> Field<N>
Returns the solutions root in the block header.
sourcepub const fn subdag_root(&self) -> Field<N>
pub const fn subdag_root(&self) -> Field<N>
Returns the subdag root in the block header.
sourcepub const fn cumulative_weight(&self) -> u128
pub const fn cumulative_weight(&self) -> u128
Returns the cumulative weight for this block.
sourcepub const fn cumulative_proof_target(&self) -> u128
pub const fn cumulative_proof_target(&self) -> u128
Returns the cumulative proof target for this block.
sourcepub const fn coinbase_target(&self) -> u64
pub const fn coinbase_target(&self) -> u64
Returns the coinbase target for this block.
sourcepub const fn proof_target(&self) -> u64
pub const fn proof_target(&self) -> u64
Returns the proof target for this block.
sourcepub const fn last_coinbase_target(&self) -> u64
pub const fn last_coinbase_target(&self) -> u64
Returns the coinbase target of the last coinbase.
sourcepub const fn last_coinbase_timestamp(&self) -> i64
pub const fn last_coinbase_timestamp(&self) -> i64
Returns the Unix timestamp (UTC) of the last coinbase.
Trait Implementations§
source§impl<'de, N: Network> Deserialize<'de> for Header<N>
impl<'de, N: Network> Deserialize<'de> for Header<N>
source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserializes the header from a JSON-string or buffer.
source§impl<N: PartialEq + Network> PartialEq for Header<N>where
N::StateRoot: PartialEq,
impl<N: PartialEq + Network> PartialEq for Header<N>where N::StateRoot: PartialEq,
impl<N: Copy + Network> Copy for Header<N>where N::StateRoot: Copy,
impl<N: Eq + Network> Eq for Header<N>where N::StateRoot: Eq,
impl<N: Network> StructuralEq for Header<N>
impl<N: Network> StructuralPartialEq for Header<N>
Auto Trait Implementations§
impl<N> RefUnwindSafe for Header<N>where N: RefUnwindSafe, <N as Environment>::Field: RefUnwindSafe, <N as Network>::StateRoot: RefUnwindSafe,
impl<N> Send for Header<N>
impl<N> Sync for Header<N>
impl<N> Unpin for Header<N>where N: Unpin, <N as Environment>::Field: Unpin, <N as Network>::StateRoot: Unpin,
impl<N> UnwindSafe for Header<N>where N: UnwindSafe, <N as Environment>::Field: UnwindSafe, <N as Network>::StateRoot: UnwindSafe,
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
§impl<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
impl<'de, T> DeserializeExt<'de> for Twhere T: DeserializeOwned,
fn take_from_value<D>( value: &mut Value, field: &str ) -> Result<T, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.