Struct snarkvm_dpc::block::template::BlockTemplate
source · [−]pub struct BlockTemplate<N: Network> { /* private fields */ }
Expand description
The block template used by miners to mine the next block.
Implementations
sourceimpl<N: Network> BlockTemplate<N>
impl<N: Network> BlockTemplate<N>
sourcepub fn new(
previous_block_hash: N::BlockHash,
block_height: u32,
block_timestamp: i64,
difficulty_target: u64,
cumulative_weight: u128,
previous_ledger_root: N::LedgerRoot,
transactions: Transactions<N>,
coinbase_record: Record<N>
) -> Self
pub fn new(
previous_block_hash: N::BlockHash,
block_height: u32,
block_timestamp: i64,
difficulty_target: u64,
cumulative_weight: u128,
previous_ledger_root: N::LedgerRoot,
transactions: Transactions<N>,
coinbase_record: Record<N>
) -> Self
Initializes a new block template.
sourcepub fn previous_block_hash(&self) -> N::BlockHash
pub fn previous_block_hash(&self) -> N::BlockHash
Returns the previous block hash.
sourcepub fn block_height(&self) -> u32
pub fn block_height(&self) -> u32
Returns the block height.
sourcepub fn block_timestamp(&self) -> i64
pub fn block_timestamp(&self) -> i64
Returns the block timestamp.
sourcepub fn difficulty_target(&self) -> u64
pub fn difficulty_target(&self) -> u64
Returns the difficulty target.
sourcepub fn cumulative_weight(&self) -> u128
pub fn cumulative_weight(&self) -> u128
Returns the cumulative weight.
sourcepub fn previous_ledger_root(&self) -> N::LedgerRoot
pub fn previous_ledger_root(&self) -> N::LedgerRoot
Returns the previous ledger root.
sourcepub fn transactions(&self) -> &Transactions<N>
pub fn transactions(&self) -> &Transactions<N>
Returns a reference to the block transactions.
sourcepub fn coinbase_record(&self) -> &Record<N>
pub fn coinbase_record(&self) -> &Record<N>
Returns the coinbase record in the block transactions.
sourcepub fn to_header_tree(&self) -> Result<MerkleTree<N::BlockHeaderRootParameters>>
pub fn to_header_tree(&self) -> Result<MerkleTree<N::BlockHeaderRootParameters>>
Returns an instance of the block header tree.
sourcepub fn to_header_root(&self) -> Result<N::BlockHeaderRoot>
pub fn to_header_root(&self) -> Result<N::BlockHeaderRoot>
Returns the block header root.
sourcepub fn compute_block_header_tree(
previous_ledger_root: N::LedgerRoot,
transactions_root: N::TransactionsRoot,
metadata: &BlockHeaderMetadata
) -> Result<MerkleTree<N::BlockHeaderRootParameters>>
pub fn compute_block_header_tree(
previous_ledger_root: N::LedgerRoot,
transactions_root: N::TransactionsRoot,
metadata: &BlockHeaderMetadata
) -> Result<MerkleTree<N::BlockHeaderRootParameters>>
Returns an instance of the block header tree.
Trait Implementations
sourceimpl<N: Clone + Network> Clone for BlockTemplate<N> where
N::BlockHash: Clone,
N::LedgerRoot: Clone,
impl<N: Clone + Network> Clone for BlockTemplate<N> where
N::BlockHash: Clone,
N::LedgerRoot: Clone,
sourcefn clone(&self) -> BlockTemplate<N>
fn clone(&self) -> BlockTemplate<N>
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<N: Debug + Network> Debug for BlockTemplate<N> where
N::BlockHash: Debug,
N::LedgerRoot: Debug,
impl<N: Debug + Network> Debug for BlockTemplate<N> where
N::BlockHash: Debug,
N::LedgerRoot: Debug,
sourceimpl<'de, N: Network> Deserialize<'de> for BlockTemplate<N>
impl<'de, N: Network> Deserialize<'de> for BlockTemplate<N>
sourcefn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserialize this value from the given Serde deserializer. Read more
sourceimpl<N: Network> Display for BlockTemplate<N>
impl<N: Network> Display for BlockTemplate<N>
sourceimpl<N: Network> FromBytes for BlockTemplate<N>
impl<N: Network> FromBytes for BlockTemplate<N>
sourceimpl<N: Network> FromStr for BlockTemplate<N>
impl<N: Network> FromStr for BlockTemplate<N>
sourceimpl<N: PartialEq + Network> PartialEq<BlockTemplate<N>> for BlockTemplate<N> where
N::BlockHash: PartialEq,
N::LedgerRoot: PartialEq,
impl<N: PartialEq + Network> PartialEq<BlockTemplate<N>> for BlockTemplate<N> where
N::BlockHash: PartialEq,
N::LedgerRoot: PartialEq,
sourcefn eq(&self, other: &BlockTemplate<N>) -> bool
fn eq(&self, other: &BlockTemplate<N>) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &BlockTemplate<N>) -> bool
fn ne(&self, other: &BlockTemplate<N>) -> bool
This method tests for !=
.
sourceimpl<N: Network> Serialize for BlockTemplate<N>
impl<N: Network> Serialize for BlockTemplate<N>
sourceimpl<N: Network> ToBytes for BlockTemplate<N>
impl<N: Network> ToBytes for BlockTemplate<N>
impl<N: Eq + Network> Eq for BlockTemplate<N> where
N::BlockHash: Eq,
N::LedgerRoot: Eq,
impl<N: Network> StructuralEq for BlockTemplate<N>
impl<N: Network> StructuralPartialEq for BlockTemplate<N>
Auto Trait Implementations
impl<N> RefUnwindSafe for BlockTemplate<N> where
N: RefUnwindSafe,
<N as Network>::BlockHash: RefUnwindSafe,
<N as Network>::Commitment: RefUnwindSafe,
<N as Network>::FunctionID: RefUnwindSafe,
<N as Network>::InnerCircuitID: RefUnwindSafe,
<N as Network>::InnerScalarField: RefUnwindSafe,
<N as Network>::LedgerRoot: RefUnwindSafe,
<N as Network>::OuterProof: RefUnwindSafe,
<N as Network>::ProgramAffineCurve: RefUnwindSafe,
<N as Network>::ProgramID: RefUnwindSafe,
<N as Network>::RecordCiphertext: RefUnwindSafe,
<N as Network>::RecordViewKey: RefUnwindSafe,
<N as Network>::SerialNumber: RefUnwindSafe,
<N as Network>::TransactionID: RefUnwindSafe,
<N as Network>::TransactionsRootParameters: RefUnwindSafe,
<N as Network>::TransitionID: RefUnwindSafe,
impl<N> Send for BlockTemplate<N>
impl<N> Sync for BlockTemplate<N>
impl<N> Unpin for BlockTemplate<N> where
N: Unpin,
<N as Network>::BlockHash: Unpin,
<N as Network>::Commitment: Unpin,
<N as Network>::FunctionID: Unpin,
<N as Network>::InnerCircuitID: Unpin,
<N as Network>::LedgerRoot: Unpin,
<N as Network>::OuterProof: Unpin,
<N as Network>::ProgramAffineCurve: Unpin,
<N as Network>::ProgramID: Unpin,
<N as Network>::RecordCiphertext: Unpin,
<N as Network>::RecordViewKey: Unpin,
<N as Network>::SerialNumber: Unpin,
<N as Network>::TransactionID: Unpin,
<N as Network>::TransitionID: Unpin,
impl<N> UnwindSafe for BlockTemplate<N> where
N: UnwindSafe,
<N as Network>::BlockHash: UnwindSafe,
<N as Network>::Commitment: UnwindSafe,
<N as Network>::FunctionID: UnwindSafe,
<N as Network>::InnerCircuitID: UnwindSafe,
<N as Network>::InnerScalarField: RefUnwindSafe,
<N as Network>::LedgerRoot: UnwindSafe,
<N as Network>::OuterProof: UnwindSafe,
<N as Network>::ProgramAffineCurve: UnwindSafe,
<N as Network>::ProgramID: UnwindSafe,
<N as Network>::RecordCiphertext: UnwindSafe,
<N as Network>::RecordViewKey: UnwindSafe,
<N as Network>::SerialNumber: UnwindSafe,
<N as Network>::TransactionID: UnwindSafe,
<N as Network>::TransactionsRootParameters: RefUnwindSafe,
<N as Network>::TransitionID: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcepub fn equivalent(&self, key: &K) -> bool
pub fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
impl<T> Pointable for T
impl<T> Pointable for T
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.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more