Struct snarkvm_ledger::Metadata
source · pub struct Metadata<N>where
N: Network,{ /* private fields */ }Implementations§
source§impl<N> Metadata<N>where
N: Network,
impl<N> Metadata<N>where
N: Network,
sourcepub fn verify(
&self,
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<(), Error>
pub fn verify( &self, 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<(), Error>
Ensures the block metadata is correct.
source§impl<N> Metadata<N>where
N: Network,
impl<N> Metadata<N>where
N: Network,
sourcepub fn new(
network: u16,
round: u64,
height: u32,
cumulative_weight: u128,
cumulative_proof_target: u128,
coinbase_target: u64,
proof_target: u64,
last_coinbase_target: u64,
last_coinbase_timestamp: i64,
timestamp: i64
) -> Result<Metadata<N>, Error>
pub fn new( network: u16, round: u64, height: u32, cumulative_weight: u128, cumulative_proof_target: u128, coinbase_target: u64, proof_target: u64, last_coinbase_target: u64, last_coinbase_timestamp: i64, timestamp: i64 ) -> Result<Metadata<N>, Error>
Initializes a new metadata with the given inputs.
source§impl<N> Metadata<N>where
N: Network,
impl<N> Metadata<N>where
N: Network,
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 block timestamp of the last coinbase.
Trait Implementations§
source§impl<'de, N> Deserialize<'de> for Metadata<N>where
N: Network,
impl<'de, N> Deserialize<'de> for Metadata<N>where
N: Network,
source§fn deserialize<D>(
deserializer: D
) -> Result<Metadata<N>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<Metadata<N>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserializes the metadata from a JSON-string or buffer.
source§impl<N> PartialEq for Metadata<N>where
N: PartialEq + Network,
impl<N> PartialEq for Metadata<N>where
N: PartialEq + Network,
source§impl<N> Serialize for Metadata<N>where
N: Network,
impl<N> Serialize for Metadata<N>where
N: Network,
source§fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serializes the metadata to a JSON-string or buffer.
source§impl<N> ToBits for Metadata<N>where
N: Network,
impl<N> ToBits for Metadata<N>where
N: Network,
source§fn write_bits_le(&self, vec: &mut Vec<bool>)
fn write_bits_le(&self, vec: &mut Vec<bool>)
Returns the little-endian bits of the metadata.
source§fn write_bits_be(&self, vec: &mut Vec<bool>)
fn write_bits_be(&self, vec: &mut Vec<bool>)
Returns the big-endian bits of the metadata.
§fn to_bits_le(&self) -> Vec<bool>
fn to_bits_le(&self) -> Vec<bool>
Returns
self as a boolean array in little-endian order.§fn to_bits_be(&self) -> Vec<bool>
fn to_bits_be(&self) -> Vec<bool>
Returns
self as a boolean array in big-endian order.impl<N> Copy for Metadata<N>where
N: Copy + Network,
impl<N> Eq for Metadata<N>where
N: Eq + Network,
impl<N> StructuralPartialEq for Metadata<N>where
N: Network,
Auto Trait Implementations§
impl<N> RefUnwindSafe for Metadata<N>where
N: RefUnwindSafe,
impl<N> Send for Metadata<N>
impl<N> Sync for Metadata<N>
impl<N> Unpin for Metadata<N>where
N: Unpin,
impl<N> UnwindSafe for Metadata<N>where
N: 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
Mutably borrows from an owned value. Read more
§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 Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.