Struct snarkvm_ledger::Ledger

source ·
pub struct Ledger<N: Network, C: ConsensusStorage<N>> { /* private fields */ }

Implementations§

source§

impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>

source

pub fn prepare_advance_to_next_block<R: Rng + CryptoRng>( &self, private_key: &PrivateKey<N>, candidate_transactions: Vec<Transaction<N>>, candidate_solutions: Option<Vec<ProverSolution<N>>>, rng: &mut R ) -> Result<Block<N>>

Returns a candidate for the next block in the ledger.

source

pub fn advance_to_next_block(&self, block: &Block<N>) -> Result<()>

Adds the given block as the next block in the ledger.

source§

impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>

source

pub fn check_transaction_basic( &self, transaction: &Transaction<N>, rejected_id: Option<Field<N>> ) -> Result<()>

Checks the given transaction is well-formed and unique.

source

pub fn check_next_block(&self, block: &Block<N>) -> Result<()>

Checks the given block is valid next block.

source§

impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>

source

pub fn contains_state_root(&self, state_root: &N::StateRoot) -> Result<bool>

Returns true if the given state root exists.

source

pub fn contains_block_height(&self, height: u32) -> Result<bool>

Returns true if the given block height exists.

source

pub fn contains_block_hash(&self, block_hash: &N::BlockHash) -> Result<bool>

Returns true if the given block hash exists.

source

pub fn contains_puzzle_commitment( &self, puzzle_commitment: &PuzzleCommitment<N> ) -> Result<bool>

Returns true if the given puzzle commitment exists.

source

pub fn contains_program_id(&self, program_id: &ProgramID<N>) -> Result<bool>

Returns true if the given program ID exists.

source

pub fn contains_transaction_id( &self, transaction_id: &N::TransactionID ) -> Result<bool>

Returns true if the given transaction ID exists.

source

pub fn contains_transition_id( &self, transition_id: &N::TransitionID ) -> Result<bool>

Returns true if the given transition ID exists.

source

pub fn contains_input_id(&self, input_id: &Field<N>) -> Result<bool>

Returns true if the given input ID exists.

source

pub fn contains_serial_number(&self, serial_number: &Field<N>) -> Result<bool>

Returns true if the given serial number exists.

source

pub fn contains_tag(&self, tag: &Field<N>) -> Result<bool>

Returns true if the given tag exists.

source

pub fn contains_output_id(&self, output_id: &Field<N>) -> Result<bool>

Returns true if the given output ID exists.

source

pub fn contains_commitment(&self, commitment: &Field<N>) -> Result<bool>

Returns true if the given commitment exists.

source

pub fn contains_checksum(&self, checksum: &Field<N>) -> bool

Returns true if the given checksum exists.

source

pub fn contains_nonce(&self, nonce: &Group<N>) -> Result<bool>

Returns true if the given nonce exists.

source

pub fn contains_tpk(&self, tpk: &Group<N>) -> Result<bool>

Returns true if the given transition public key exists.

source

pub fn contains_tcm(&self, tcm: &Field<N>) -> Result<bool>

Returns true if the given transition commitment exists.

source§

impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>

source

pub fn find_block_height_from_state_root( &self, state_root: N::StateRoot ) -> Result<Option<u32>>

Returns the block height that contains the given state root.

source

pub fn find_block_hash( &self, transaction_id: &N::TransactionID ) -> Result<Option<N::BlockHash>>

Returns the block hash that contains the given transaction ID.

source

pub fn find_block_height_from_puzzle_commitment( &self, puzzle_commitment: &PuzzleCommitment<N> ) -> Result<Option<u32>>

Returns the block height that contains the given puzzle commitment.

source

pub fn find_transaction_id_from_program_id( &self, program_id: &ProgramID<N> ) -> Result<Option<N::TransactionID>>

Returns the transaction ID that contains the given program ID.

source

pub fn find_transaction_id_from_transition_id( &self, transition_id: &N::TransitionID ) -> Result<Option<N::TransactionID>>

Returns the transaction ID that contains the given transition ID.

source

pub fn find_transition_id(&self, id: &Field<N>) -> Result<N::TransitionID>

Returns the transition ID that contains the given input ID or output ID.

source

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.

source

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.

source§

impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>

source

pub fn get_state_root(&self, block_height: u32) -> Result<Option<N::StateRoot>>

Returns the state root that contains the given block height.

source

pub fn get_state_path_for_commitment( &self, commitment: &Field<N> ) -> Result<StatePath<N>>

Returns a state path for the given commitment.

source

pub fn get_epoch_challenge( &self, block_height: u32 ) -> Result<EpochChallenge<N>>

Returns the epoch challenge for the given block height.

source

pub fn get_block(&self, height: u32) -> Result<Block<N>>

Returns the block for the given block height.

source

pub fn get_blocks(&self, heights: Range<u32>) -> Result<Vec<Block<N>>>

Returns the blocks in the given block range. The range is inclusive of the start and exclusive of the end.

source

pub fn get_block_by_hash(&self, block_hash: &N::BlockHash) -> Result<Block<N>>

Returns the block for the given block hash.

source

pub fn get_height(&self, block_hash: &N::BlockHash) -> Result<u32>

Returns the block height for the given block hash.

source

pub fn get_hash(&self, height: u32) -> Result<N::BlockHash>

Returns the block hash for the given block height.

source

pub fn get_previous_hash(&self, height: u32) -> Result<N::BlockHash>

Returns the previous block hash for the given block height.

source

pub fn get_header(&self, height: u32) -> Result<Header<N>>

Returns the block header for the given block height.

source

pub fn get_transactions(&self, height: u32) -> Result<Transactions<N>>

Returns the block transactions for the given block height.

source

pub fn get_transaction( &self, transaction_id: N::TransactionID ) -> Result<Transaction<N>>

Returns the transaction for the given transaction ID.

source

pub fn get_confirmed_transaction( &self, transaction_id: N::TransactionID ) -> Result<ConfirmedTransaction<N>>

Returns the confirmed transaction for the given transaction ID.

source

pub fn get_program(&self, program_id: ProgramID<N>) -> Result<Program<N>>

Returns the program for the given program ID.

source

pub fn get_coinbase(&self, height: u32) -> Result<Option<CoinbaseSolution<N>>>

Returns the block coinbase solution for the given block height.

source

pub fn get_signature(&self, height: u32) -> Result<Signature<N>>

Returns the block signature for the given block height.

source§

impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>

source

pub fn state_roots(&self) -> impl '_ + Iterator<Item = Cow<'_, N::StateRoot>>

Returns an iterator over the state roots, for all blocks in self.

source

pub fn puzzle_commitments( &self ) -> impl '_ + Iterator<Item = Cow<'_, PuzzleCommitment<N>>>

Returns an iterator over the puzzle commitments, for all blocks in self.

source

pub fn program_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, ProgramID<N>>>

Returns an iterator over the program IDs, for all transactions in self.

source

pub fn programs(&self) -> impl '_ + Iterator<Item = Cow<'_, Program<N>>>

Returns an iterator over the programs, for all transactions in self.

source

pub fn transaction_ids( &self ) -> impl '_ + Iterator<Item = Cow<'_, N::TransactionID>>

Returns an iterator over the transaction IDs, for all transactions in self.

source

pub fn transition_ids( &self ) -> impl '_ + Iterator<Item = Cow<'_, N::TransitionID>>

Returns an iterator over the transition IDs, for all transitions.

source

pub fn input_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>>

Returns an iterator over the input IDs, for all transition inputs.

source

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.

source

pub fn tags(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>>

Returns an iterator over the tags, for all transition inputs that are records.

source

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.

source

pub fn commitments(&self) -> impl '_ + Iterator<Item = Cow<'_, Field<N>>>

Returns an iterator over the commitments, for all transition outputs that are records.

source

pub fn nonces(&self) -> impl '_ + Iterator<Item = Cow<'_, Group<N>>>

Returns an iterator over the nonces, for all transition outputs that are records.

source

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.

source

pub fn transition_public_keys( &self ) -> impl '_ + Iterator<Item = Cow<'_, Group<N>>>

Returns an iterator over the transition public keys, for all transactions.

source§

impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>

source

pub fn load(genesis: Block<N>, dev: Option<u16>) -> Result<Self>

Loads the ledger from storage.

source

pub fn load_unchecked(genesis: Block<N>, dev: Option<u16>) -> Result<Self>

Loads the ledger from storage, without performing integrity checks.

source

pub const fn vm(&self) -> &VM<N, C>

Returns the VM.

source

pub const fn coinbase_puzzle(&self) -> &CoinbasePuzzle<N>

Returns the coinbase puzzle.

source

pub fn latest_committee(&self) -> IndexSet<Address<N>>

Returns the latest committee.

source

pub fn latest_state_root(&self) -> N::StateRoot

Returns the latest state root.

source

pub fn latest_block(&self) -> Block<N>

Returns the latest block.

source

pub fn latest_round(&self) -> u64

Returns the latest round number.

source

pub fn latest_height(&self) -> u32

Returns the latest block height.

source

pub fn latest_hash(&self) -> N::BlockHash

Returns the latest block hash.

source

pub fn latest_header(&self) -> Header<N>

Returns the latest block header.

source

pub fn latest_total_supply_in_microcredits(&self) -> u64

Returns the latest total supply in microcredits.

source

pub fn latest_cumulative_weight(&self) -> u128

Returns the latest latest cumulative weight.

source

pub fn latest_coinbase_accumulator_point(&self) -> Field<N>

Returns the latest block coinbase accumulator point.

source

pub fn latest_coinbase_target(&self) -> u64

Returns the latest block coinbase target.

source

pub fn latest_proof_target(&self) -> u64

Returns the latest block proof target.

source

pub fn last_coinbase_target(&self) -> u64

Returns the last coinbase target.

source

pub fn last_coinbase_timestamp(&self) -> i64

Returns the last coinbase timestamp.

source

pub fn latest_timestamp(&self) -> i64

Returns the latest block timestamp.

source

pub fn latest_transactions(&self) -> Transactions<N>

Returns the latest block transactions.

source

pub fn latest_epoch_number(&self) -> u32

Returns the latest epoch number.

source

pub fn latest_epoch_challenge(&self) -> Result<EpochChallenge<N>>

Returns the latest epoch challenge.

source§

impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>

source

pub fn find_unspent_credits_records( &self, view_key: &ViewKey<N> ) -> Result<RecordMap<N>>

Returns the unspent credits.aleo records.

source

pub fn create_deploy( &self, private_key: &PrivateKey<N>, program: &Program<N>, priority_fee_in_microcredits: u64, query: Option<Query<N, C::BlockStorage>> ) -> Result<Transaction<N>>

Creates a deploy transaction.

The priority_fee_in_microcredits is an additional fee on top of the deployment fee.

source

pub fn create_transfer( &self, private_key: &PrivateKey<N>, to: Address<N>, amount_in_microcredits: u64, priority_fee_in_microcredits: u64, query: Option<Query<N, C::BlockStorage>> ) -> Result<Transaction<N>>

Creates a transfer transaction.

The priority_fee_in_microcredits is an additional fee on top of the execution fee.

Trait Implementations§

source§

impl<N: Clone + Network, C: Clone + ConsensusStorage<N>> Clone for Ledger<N, C>

source§

fn clone(&self) -> Ledger<N, C>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<N, C> !RefUnwindSafe for Ledger<N, C>

§

impl<N, C> Send for Ledger<N, C>

§

impl<N, C> Sync for Ledger<N, C>

§

impl<N, C> Unpin for Ledger<N, C>where C: Unpin, N: Unpin, <N as Network>::BlockHash: Unpin, <N as Environment>::Field: Unpin, <<N as Environment>::PairingCurve as PairingEngine>::G1Affine: Unpin, <N as Environment>::Projective: Unpin, <N as Environment>::Scalar: Unpin, <N as Network>::StateRoot: Unpin, <N as Network>::TransactionID: Unpin, <N as Network>::TransitionID: Unpin,

§

impl<N, C> !UnwindSafe for Ledger<N, C>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

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
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more