Struct snarkvm_compiler::Ledger
source · [−]pub struct Ledger<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> { /* private fields */ }
Implementations
sourceimpl<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> Ledger<N, B, P>
impl<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> Ledger<N, B, P>
sourcepub fn contains_state_root(&self, _state_root: &Field<N>) -> bool
pub fn contains_state_root(&self, _state_root: &Field<N>) -> bool
Returns true
if the given state root exists.
sourcepub fn contains_block_hash(&self, block_hash: &N::BlockHash) -> Result<bool>
pub fn contains_block_hash(&self, block_hash: &N::BlockHash) -> Result<bool>
Returns true
if the given block hash exists.
sourcepub fn contains_block_height(&self, height: u32) -> Result<bool>
pub fn contains_block_height(&self, height: u32) -> Result<bool>
Returns true
if the given block height exists.
sourcepub fn contains_transaction_id(
&self,
transaction_id: &N::TransactionID
) -> Result<bool>
pub fn contains_transaction_id(
&self,
transaction_id: &N::TransactionID
) -> Result<bool>
Returns true
if the given transaction ID exists.
sourcepub fn contains_program_id(&self, program_id: &ProgramID<N>) -> Result<bool>
pub fn contains_program_id(&self, program_id: &ProgramID<N>) -> Result<bool>
Returns true
if the given program ID exists.
sourcepub fn contains_transition_id(
&self,
transition_id: &N::TransitionID
) -> Result<bool>
pub fn contains_transition_id(
&self,
transition_id: &N::TransitionID
) -> Result<bool>
Returns true
if the given transition ID exists.
sourcepub fn contains_input_id(&self, input_id: &Field<N>) -> Result<bool>
pub fn contains_input_id(&self, input_id: &Field<N>) -> Result<bool>
Returns true
if the given input ID exists.
sourcepub fn contains_serial_number(&self, serial_number: &Field<N>) -> Result<bool>
pub fn contains_serial_number(&self, serial_number: &Field<N>) -> Result<bool>
Returns true
if the given serial number exists.
sourcepub fn contains_tag(&self, tag: &Field<N>) -> Result<bool>
pub fn contains_tag(&self, tag: &Field<N>) -> Result<bool>
Returns true
if the given tag exists.
sourcepub fn contains_output_id(&self, output_id: &Field<N>) -> Result<bool>
pub fn contains_output_id(&self, output_id: &Field<N>) -> Result<bool>
Returns true
if the given output ID exists.
sourcepub fn contains_commitment(&self, commitment: &Field<N>) -> Result<bool>
pub fn contains_commitment(&self, commitment: &Field<N>) -> Result<bool>
Returns true
if the given commitment exists.
sourcepub fn contains_checksum(&self, checksum: &Field<N>) -> bool
pub fn contains_checksum(&self, checksum: &Field<N>) -> bool
Returns true
if the given checksum exists.
sourcepub fn contains_nonce(&self, nonce: &Group<N>) -> Result<bool>
pub fn contains_nonce(&self, nonce: &Group<N>) -> Result<bool>
Returns true
if the given nonce exists.
sourcepub fn contains_tpk(&self, tpk: &Group<N>) -> Result<bool>
pub fn contains_tpk(&self, tpk: &Group<N>) -> Result<bool>
Returns true
if the given transition public key exists.
sourcepub fn contains_tcm(&self, tcm: &Field<N>) -> Result<bool>
pub fn contains_tcm(&self, tcm: &Field<N>) -> Result<bool>
Returns true
if the given transition commitment exists.
sourceimpl<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> Ledger<N, B, P>
impl<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> Ledger<N, B, P>
sourcepub fn find_record_ciphertexts<'a>(
&'a self,
view_key: &'a ViewKey<N>,
filter: RecordsFilter<N>
) -> Result<impl '_ + Iterator<Item = (Field<N>, Cow<'_, Record<N, Ciphertext<N>>>)>>
pub fn find_record_ciphertexts<'a>(
&'a self,
view_key: &'a ViewKey<N>,
filter: RecordsFilter<N>
) -> Result<impl '_ + Iterator<Item = (Field<N>, Cow<'_, Record<N, Ciphertext<N>>>)>>
Returns the record ciphertexts that belong to the given view key.
sourcepub fn find_records<'a>(
&'a self,
view_key: &'a ViewKey<N>,
filter: RecordsFilter<N>
) -> Result<impl '_ + Iterator<Item = (Field<N>, Record<N, Plaintext<N>>)>>
pub fn find_records<'a>(
&'a self,
view_key: &'a ViewKey<N>,
filter: RecordsFilter<N>
) -> Result<impl '_ + Iterator<Item = (Field<N>, Record<N, Plaintext<N>>)>>
Returns the records that belong to the given view key.
sourceimpl<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> Ledger<N, B, P>
impl<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> Ledger<N, B, P>
sourcepub fn get_block(&self, height: u32) -> Result<Block<N>>
pub fn get_block(&self, height: u32) -> Result<Block<N>>
Returns the block for the given block height.
sourcepub fn get_hash(&self, height: u32) -> Result<N::BlockHash>
pub fn get_hash(&self, height: u32) -> Result<N::BlockHash>
Returns the block hash for the given block height.
sourcepub fn get_previous_hash(&self, height: u32) -> Result<N::BlockHash>
pub fn get_previous_hash(&self, height: u32) -> Result<N::BlockHash>
Returns the previous block hash for the given block height.
sourcepub fn get_header(&self, height: u32) -> Result<Header<N>>
pub fn get_header(&self, height: u32) -> Result<Header<N>>
Returns the block header for the given block height.
sourcepub fn get_transactions(&self, height: u32) -> Result<Transactions<N>>
pub fn get_transactions(&self, height: u32) -> Result<Transactions<N>>
Returns the block transactions for the given block height.
sourcepub fn get_transaction(
&self,
transaction_id: N::TransactionID
) -> Result<Transaction<N>>
pub fn get_transaction(
&self,
transaction_id: N::TransactionID
) -> Result<Transaction<N>>
Returns the transaction for the given transaction id.
sourcepub fn get_signature(&self, height: u32) -> Result<Signature<N>>
pub fn get_signature(&self, height: u32) -> Result<Signature<N>>
Returns the block signature for the given block height.
sourceimpl<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> Ledger<N, B, P>
impl<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> Ledger<N, B, P>
sourcepub fn transaction_ids(
&self
) -> impl '_ + Iterator<Item = Cow<'_, N::TransactionID>>
pub fn transaction_ids(
&self
) -> impl '_ + Iterator<Item = Cow<'_, N::TransactionID>>
Returns an iterator over the transaction IDs, for all transactions in self
.
sourcepub fn program_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, ProgramID<N>>>
pub fn program_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, ProgramID<N>>>
Returns an iterator over the program IDs, for all transactions in self
.
sourcepub fn programs(&self) -> impl '_ + Iterator<Item = Cow<'_, Program<N>>>
pub fn programs(&self) -> impl '_ + Iterator<Item = Cow<'_, Program<N>>>
Returns an iterator over the programs, for all transactions in self
.
sourcepub fn transition_ids(
&self
) -> impl '_ + Iterator<Item = Cow<'_, N::TransitionID>>
pub fn transition_ids(
&self
) -> impl '_ + Iterator<Item = Cow<'_, N::TransitionID>>
Returns an iterator over the transition IDs, for all transitions.
sourcepub fn input_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>>
pub fn input_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>>
Returns an iterator over the input IDs, for all transition inputs.
sourcepub fn serial_numbers(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>>
pub fn serial_numbers(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>>
Returns an iterator over the serial numbers, for all transition inputs that are records.
Returns an iterator over the tags, for all transition inputs that are records.
sourcepub fn output_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>>
pub fn output_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>>
Returns an iterator over the output IDs, for all transition outputs that are records.
sourcepub fn commitments(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>>
pub fn commitments(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>>
Returns an iterator over the commitments, for all transition outputs that are records.
sourcepub fn nonces(&self) -> impl '_ + Iterator<Item = Cow<'_, Group<N>>>
pub fn nonces(&self) -> impl '_ + Iterator<Item = Cow<'_, Group<N>>>
Returns an iterator over the nonces, for all transition outputs that are records.
sourcepub fn records(
&self
) -> impl '_ + Iterator<Item = (Cow<'_, Field<N>>, Cow<'_, Record<N, Ciphertext<N>>>)>
pub fn records(
&self
) -> impl '_ + Iterator<Item = (Cow<'_, Field<N>>, Cow<'_, Record<N, Ciphertext<N>>>)>
Returns an iterator over the (commitment, record)
pairs, for all transition outputs that are records.
sourcepub fn transition_public_keys(
&self
) -> impl '_ + Iterator<Item = Cow<'_, Group<N>>>
pub fn transition_public_keys(
&self
) -> impl '_ + Iterator<Item = Cow<'_, Group<N>>>
Returns an iterator over the transition public keys, for all transactions.
sourceimpl<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> Ledger<N, B, P>
impl<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> Ledger<N, B, P>
sourcepub const fn latest_state_root(&self) -> &Field<N>
pub const fn latest_state_root(&self) -> &Field<N>
Returns the latest state root.
sourcepub fn latest_block(&self) -> Result<Block<N>>
pub fn latest_block(&self) -> Result<Block<N>>
Returns the latest block.
sourcepub const fn latest_hash(&self) -> N::BlockHash
pub const fn latest_hash(&self) -> N::BlockHash
Returns the latest block hash.
sourcepub const fn latest_height(&self) -> u32
pub const fn latest_height(&self) -> u32
Returns the latest block height.
sourcepub const fn latest_round(&self) -> u64
pub const fn latest_round(&self) -> u64
Returns the latest round number.
sourcepub fn latest_coinbase_target(&self) -> Result<u64>
pub fn latest_coinbase_target(&self) -> Result<u64>
Returns the latest block coinbase target.
sourcepub fn latest_proof_target(&self) -> Result<u64>
pub fn latest_proof_target(&self) -> Result<u64>
Returns the latest block proof target.
sourcepub fn latest_timestamp(&self) -> Result<i64>
pub fn latest_timestamp(&self) -> Result<i64>
Returns the latest block timestamp.
sourcepub fn latest_transactions(&self) -> Result<Transactions<N>>
pub fn latest_transactions(&self) -> Result<Transactions<N>>
Returns the latest block transactions.
sourceimpl<N: Network> Ledger<N, BlockMemory<N>, ProgramMemory<N>>
impl<N: Network> Ledger<N, BlockMemory<N>, ProgramMemory<N>>
sourceimpl<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> Ledger<N, B, P>
impl<N: Network, B: BlockStorage<N>, P: ProgramStorage<N>> Ledger<N, B, P>
sourcepub fn from(blocks: BlockStore<N, B>, store: ProgramStore<N, P>) -> Result<Self>
pub fn from(blocks: BlockStore<N, B>, store: ProgramStore<N, P>) -> Result<Self>
Initializes the Ledger
from storage.
sourcepub fn new_with_genesis(genesis: &Block<N>, address: Address<N>) -> Result<Self>
pub fn new_with_genesis(genesis: &Block<N>, address: Address<N>) -> Result<Self>
Initializes a new instance of Ledger
with the given genesis block.
sourcepub fn add_to_memory_pool(&mut self, transaction: Transaction<N>) -> Result<()>
pub fn add_to_memory_pool(&mut self, transaction: Transaction<N>) -> Result<()>
Appends the given transaction to the memory pool.
sourcepub fn propose_next_block<R: Rng + CryptoRng>(
&self,
private_key: &PrivateKey<N>,
rng: &mut R
) -> Result<Block<N>>
pub fn propose_next_block<R: Rng + CryptoRng>(
&self,
private_key: &PrivateKey<N>,
rng: &mut R
) -> Result<Block<N>>
Returns a candidate for the next block in the ledger.
sourcepub fn check_next_block(&self, block: &Block<N>) -> Result<()>
pub fn check_next_block(&self, block: &Block<N>) -> Result<()>
Checks the given block is valid next block.
sourcepub fn add_next_block(&mut self, block: &Block<N>) -> Result<()>
pub fn add_next_block(&mut self, block: &Block<N>) -> Result<()>
Adds the given block as the next block in the chain.
sourcepub const fn block_tree(&self) -> &BlockTree<N>
pub const fn block_tree(&self) -> &BlockTree<N>
Returns the block tree.
sourcepub const fn memory_pool(&self) -> &IndexMap<N::TransactionID, Transaction<N>>
pub const fn memory_pool(&self) -> &IndexMap<N::TransactionID, Transaction<N>>
Returns the memory pool.
sourcepub fn to_state_path(&self, commitment: &Field<N>) -> Result<StatePath<N>>
pub fn to_state_path(&self, commitment: &Field<N>) -> Result<StatePath<N>>
Returns a state path for the given commitment.
Trait Implementations
sourceimpl<N: Clone + Network, B: Clone + BlockStorage<N>, P: Clone + ProgramStorage<N>> Clone for Ledger<N, B, P> where
N::BlockHash: Clone,
B::TransactionStorage: Clone,
B::TransitionStorage: Clone,
N::TransactionID: Clone,
impl<N: Clone + Network, B: Clone + BlockStorage<N>, P: Clone + ProgramStorage<N>> Clone for Ledger<N, B, P> where
N::BlockHash: Clone,
B::TransactionStorage: Clone,
B::TransitionStorage: Clone,
N::TransactionID: Clone,
Auto Trait Implementations
impl<N, B, P> !RefUnwindSafe for Ledger<N, B, P>
impl<N, B, P> Send for Ledger<N, B, P> where
B: Send,
P: Send,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::InputStorage as InputStorage<N>>::ConstantMap: Send,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::OutputStorage as OutputStorage<N>>::ConstantMap: Send,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::InputStorage as InputStorage<N>>::ExternalRecordMap: Send,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::OutputStorage as OutputStorage<N>>::ExternalRecordMap: Send,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::FeeMap: Send,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::FinalizeMap: Send,
<<B as BlockStorage<N>>::TransactionStorage as TransactionStorage<N>>::IDMap: Send,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::InputStorage: Send,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::LocatorMap: Send,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::OutputStorage: Send,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::InputStorage as InputStorage<N>>::PrivateMap: Send,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::OutputStorage as OutputStorage<N>>::PrivateMap: Send,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::ProofMap: Send,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::InputStorage as InputStorage<N>>::PublicMap: Send,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::OutputStorage as OutputStorage<N>>::PublicMap: Send,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::InputStorage as InputStorage<N>>::RecordMap: Send,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::OutputStorage as OutputStorage<N>>::RecordMap: Send,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::OutputStorage as OutputStorage<N>>::RecordNonceMap: Send,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::InputStorage as InputStorage<N>>::RecordTagMap: Send,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::ReverseTCMMap: Send,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::ReverseTPKMap: Send,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::TCMMap: Send,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::TPKMap: Send,
<B as BlockStorage<N>>::TransactionStorage: Send,
<B as BlockStorage<N>>::TransitionStorage: Send,
impl<N, B, P> Sync for Ledger<N, B, P>
impl<N, B, P> Unpin for Ledger<N, B, P> where
B: Unpin,
N: Unpin,
P: Unpin,
<N as Network>::BlockHash: Unpin,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::InputStorage as InputStorage<N>>::ConstantMap: Unpin,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::OutputStorage as OutputStorage<N>>::ConstantMap: Unpin,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::InputStorage as InputStorage<N>>::ExternalRecordMap: Unpin,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::OutputStorage as OutputStorage<N>>::ExternalRecordMap: Unpin,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::FeeMap: Unpin,
<N as Environment>::Field: Unpin,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::FinalizeMap: Unpin,
<<N as Environment>::PairingCurve as PairingEngine>::G1Affine: Unpin,
<<N as Environment>::PairingCurve as PairingEngine>::G2Affine: Unpin,
<<B as BlockStorage<N>>::TransactionStorage as TransactionStorage<N>>::IDMap: Unpin,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::InputStorage: Unpin,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::LocatorMap: Unpin,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::OutputStorage: Unpin,
<<<N as Environment>::PairingCurve as PairingEngine>::G2Affine as PairingCurve>::Prepared: Unpin,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::InputStorage as InputStorage<N>>::PrivateMap: Unpin,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::OutputStorage as OutputStorage<N>>::PrivateMap: Unpin,
<N as Environment>::Projective: Unpin,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::ProofMap: Unpin,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::InputStorage as InputStorage<N>>::PublicMap: Unpin,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::OutputStorage as OutputStorage<N>>::PublicMap: Unpin,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::InputStorage as InputStorage<N>>::RecordMap: Unpin,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::OutputStorage as OutputStorage<N>>::RecordMap: Unpin,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::OutputStorage as OutputStorage<N>>::RecordNonceMap: Unpin,
<<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::InputStorage as InputStorage<N>>::RecordTagMap: Unpin,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::ReverseTCMMap: Unpin,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::ReverseTPKMap: Unpin,
<N as Environment>::Scalar: Unpin,
<N as Network>::StateRoot: Unpin,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::TCMMap: Unpin,
<<B as BlockStorage<N>>::TransitionStorage as TransitionStorage<N>>::TPKMap: Unpin,
<N as Network>::TransactionID: Unpin,
<B as BlockStorage<N>>::TransactionStorage: Unpin,
<N as Network>::TransitionID: Unpin,
<B as BlockStorage<N>>::TransitionStorage: Unpin,
impl<N, B, P> !UnwindSafe for Ledger<N, B, P>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more