pub struct Ledger<N: Network, C: ConsensusStorage<N>>(/* private fields */);Expand description
State of the entire chain.
All stored state is held in the VM, while Ledger holds the VM and relevant cache data.
The constructor is Ledger::load,
which loads the ledger from storage,
or initializes it with the genesis block if the storage is empty
Implementations§
Source§impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
Sourcepub fn check_block_subdag(
&self,
block: Block<N>,
prefix: &[PendingBlock<N>],
) -> Result<PendingBlock<N>, CheckBlockError<N>>
pub fn check_block_subdag( &self, block: Block<N>, prefix: &[PendingBlock<N>], ) -> Result<PendingBlock<N>, CheckBlockError<N>>
Checks that the subDAG in a given block is valid, but does not fully verify the block.
§Arguments
block- The block to check.prefix- A sequence of blocks between the block to check and the current height of the ledger.
§Returns
- On success, a
PendingBlockrepresenting the block that was checked. Once the prefix of this block has been fully added to the ledger, thePendingBlockcan then be passed toSelf::check_block_contentto fully verify it. - On failure, a
CheckBlockErrordescribing the reason the block was rejected.
§Notes
- This does not check that the header of the block is correct or execute/verify any of the transmissions contained within it.
- In most cases, you want to use
Self::check_next_blockinstead to perform a full verification. - This will reject any blocks with a height <= the current height and any blocks with a height >= the current height + GC. For the former, a valid block already exists and,for the latter, the comittee is still unknown.
- This function executes atomically, in that there is guaranteed to be no concurrent updates to the ledger during its execution.
However there are no ordering guarantees between multiple invocations of this function,
Self::check_block_contentandSelf::advance_to_next_block.
Sourcepub fn check_next_block<R: CryptoRng + Rng>(
&self,
block: &Block<N>,
rng: &mut R,
) -> Result<()>
pub fn check_next_block<R: CryptoRng + Rng>( &self, block: &Block<N>, rng: &mut R, ) -> Result<()>
Checks the given block is a valid next block with regard to the current state/height of the Ledger.
§Panics
This function panics if called from an async context.
Sourcepub fn check_block_content<R: CryptoRng + Rng>(
&self,
block: PendingBlock<N>,
rng: &mut R,
) -> Result<Block<N>, CheckBlockError<N>>
pub fn check_block_content<R: CryptoRng + Rng>( &self, block: PendingBlock<N>, rng: &mut R, ) -> Result<Block<N>, CheckBlockError<N>>
Takes a pending block and performs the remaining checks to full verify it.
§Arguments
This takes a PendingBlock as input, which is the output of a successful call to Self::check_block_subdag.
The latter already verified the block’s DAG and certificate signatures.
§Return Value
This returns a Block on success representing the fully verified block.
§Notes
- This check can only succeed for pending blocks that are a direct successor of the latest block in the ledger.
- Execution of this function is atomic, and there is guaranteed to be no concurrent update to the ledger during its execution.
- Even though this function may return
Ok(block), advancing the ledger to this block may still fail, if there was an update to the ledger between callingcheck_block_contentandadvance_to_next_block. If your implementation requires atomicity across these two steps, you need to implement your own locking mechanism.
§Panics
This function panics if called from an async context.
Source§impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
Sourcepub fn prepare_advance_to_next_quorum_block<R: Rng + CryptoRng>(
&self,
subdag: Subdag<N>,
transmissions: IndexMap<TransmissionID<N>, Transmission<N>>,
rng: &mut R,
) -> Result<Block<N>>
pub fn prepare_advance_to_next_quorum_block<R: Rng + CryptoRng>( &self, subdag: Subdag<N>, transmissions: IndexMap<TransmissionID<N>, Transmission<N>>, rng: &mut R, ) -> Result<Block<N>>
Returns a candidate for the next block in the ledger, using a committed subdag and its transmissions.
This candidate can then be passed to Ledger::advance_to_next_block to be added to the ledger.
§Panics
This function panics if called from an async context.
Sourcepub fn prepare_advance_to_next_beacon_block<R: Rng + CryptoRng>(
&self,
private_key: &PrivateKey<N>,
candidate_ratifications: Vec<Ratify<N>>,
candidate_solutions: Vec<Solution<N>>,
candidate_transactions: Vec<Transaction<N>>,
rng: &mut R,
) -> Result<Block<N>>
pub fn prepare_advance_to_next_beacon_block<R: Rng + CryptoRng>( &self, private_key: &PrivateKey<N>, candidate_ratifications: Vec<Ratify<N>>, candidate_solutions: Vec<Solution<N>>, candidate_transactions: Vec<Transaction<N>>, rng: &mut R, ) -> Result<Block<N>>
Returns a candidate for the next block in the ledger.
This candidate can then be passed to Ledger::advance_to_next_block to be added to the ledger.
Note, that beacon blocks are only used for testing purposes.
Production code will most likely used [Ledger::prepare_advance_to_next_quorum_block] instead.
§Panics
This function panics if called from an async context.
Sourcepub fn advance_to_next_block(&self, block: &Block<N>) -> Result<()>
pub fn advance_to_next_block(&self, block: &Block<N>) -> Result<()>
Adds the given block as the next block in the ledger.
This function expects a valid block, that either was created by a trusted source, or successfully passed
the blocks checks (e.g. Ledger::check_next_block).
Note, that it is still possible that this function returns an error for a valid block, if there are concurrent tasks
updating the ledger.
§Panics
This function panics if called from an async context.
Source§impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
Sourcepub fn check_transaction_basic<R: CryptoRng + Rng>(
&self,
transaction: &Transaction<N>,
rejected_id: Option<Field<N>>,
rng: &mut R,
) -> Result<()>
pub fn check_transaction_basic<R: CryptoRng + Rng>( &self, transaction: &Transaction<N>, rejected_id: Option<Field<N>>, rng: &mut R, ) -> Result<()>
Checks the given transaction is well-formed and unique.
Sourcepub fn check_transactions_basic<R: CryptoRng + Rng>(
&self,
transactions: &[(&Transaction<N>, Option<Field<N>>)],
rng: &mut R,
) -> Result<()>
pub fn check_transactions_basic<R: CryptoRng + Rng>( &self, transactions: &[(&Transaction<N>, Option<Field<N>>)], rng: &mut R, ) -> Result<()>
Checks that the given list of transactions are well-formed and unique.
Source§impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
Sourcepub fn contains_state_root(&self, state_root: &N::StateRoot) -> Result<bool>
pub fn contains_state_root(&self, state_root: &N::StateRoot) -> Result<bool>
Returns true if the given state root 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_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_certificate(&self, certificate_id: &Field<N>) -> Result<bool>
pub fn contains_certificate(&self, certificate_id: &Field<N>) -> Result<bool>
Returns true if the given batch certificate 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_transmission(
&self,
transmission_id: &TransmissionID<N>,
) -> Result<bool>
pub fn contains_transmission( &self, transmission_id: &TransmissionID<N>, ) -> Result<bool>
Returns true if the transmission exists in the ledger.
Sourcepub fn contains_solution_id(&self, solution_id: &SolutionID<N>) -> Result<bool>
pub fn contains_solution_id(&self, solution_id: &SolutionID<N>) -> Result<bool>
Returns true if the given solution ID 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_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.
Source§impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
Sourcepub fn find_block_height_from_state_root(
&self,
state_root: N::StateRoot,
) -> Result<Option<u32>>
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.
Sourcepub fn find_block_hash(
&self,
transaction_id: &N::TransactionID,
) -> Result<Option<N::BlockHash>>
pub fn find_block_hash( &self, transaction_id: &N::TransactionID, ) -> Result<Option<N::BlockHash>>
Returns the block hash that contains the given transaction ID.
Sourcepub fn find_block_height_from_solution_id(
&self,
solution_id: &SolutionID<N>,
) -> Result<Option<u32>>
pub fn find_block_height_from_solution_id( &self, solution_id: &SolutionID<N>, ) -> Result<Option<u32>>
Returns the block height that contains the given solution ID.
Sourcepub fn find_latest_transaction_id_from_program_id(
&self,
program_id: &ProgramID<N>,
) -> Result<Option<N::TransactionID>>
pub fn find_latest_transaction_id_from_program_id( &self, program_id: &ProgramID<N>, ) -> Result<Option<N::TransactionID>>
Returns the latest transaction ID that contains the given program ID.
Sourcepub fn find_transaction_id_from_program_id_and_edition(
&self,
program_id: &ProgramID<N>,
edition: u16,
) -> Result<Option<N::TransactionID>>
pub fn find_transaction_id_from_program_id_and_edition( &self, program_id: &ProgramID<N>, edition: u16, ) -> Result<Option<N::TransactionID>>
Returns the transaction ID that contains the given program ID and edition.
Sourcepub fn find_transaction_id_from_transition_id(
&self,
transition_id: &N::TransitionID,
) -> Result<Option<N::TransactionID>>
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.
Sourcepub fn find_transition_id(&self, id: &Field<N>) -> Result<N::TransitionID>
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.
Sourcepub fn find_record_ciphertexts<'a>(
&'a self,
view_key: &'a ViewKey<N>,
filter: RecordsFilter<N>,
) -> Result<impl 'a + Iterator<Item = (Field<N>, Cow<'a, Record<N, Ciphertext<N>>>)>>
pub fn find_record_ciphertexts<'a>( &'a self, view_key: &'a ViewKey<N>, filter: RecordsFilter<N>, ) -> Result<impl 'a + Iterator<Item = (Field<N>, Cow<'a, 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 'a + 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 'a + 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>
impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
Sourcepub fn get_committee(&self, block_height: u32) -> Result<Option<Committee<N>>>
pub fn get_committee(&self, block_height: u32) -> Result<Option<Committee<N>>>
Returns the committee for the given block height.
Sourcepub fn get_committee_for_round(
&self,
round: u64,
) -> Result<Option<Committee<N>>>
pub fn get_committee_for_round( &self, round: u64, ) -> Result<Option<Committee<N>>>
Returns the committee for the given round.
Sourcepub fn get_committee_lookback_for_round(
&self,
round: u64,
) -> Result<Option<Committee<N>>>
pub fn get_committee_lookback_for_round( &self, round: u64, ) -> Result<Option<Committee<N>>>
Returns the committee lookback for the given round.
Sourcepub fn get_state_root(&self, block_height: u32) -> Result<Option<N::StateRoot>>
pub fn get_state_root(&self, block_height: u32) -> Result<Option<N::StateRoot>>
Returns the state root that contains the given block height.
Sourcepub fn get_state_path_for_commitment(
&self,
commitment: &Field<N>,
) -> Result<StatePath<N>>
pub fn get_state_path_for_commitment( &self, commitment: &Field<N>, ) -> Result<StatePath<N>>
Returns a state path for the given commitment.
Sourcepub fn get_state_paths_for_commitments(
&self,
commitments: &[Field<N>],
) -> Result<Vec<StatePath<N>>>
pub fn get_state_paths_for_commitments( &self, commitments: &[Field<N>], ) -> Result<Vec<StatePath<N>>>
Returns a list of state paths for the given list of commitments.
Sourcepub fn get_epoch_hash(&self, block_height: u32) -> Result<N::BlockHash>
pub fn get_epoch_hash(&self, block_height: u32) -> Result<N::BlockHash>
Returns the epoch hash for the given block height.
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 try_get_block(&self, height: u32) -> Result<Option<Block<N>>>
pub fn try_get_block(&self, height: u32) -> Result<Option<Block<N>>>
Returns the block for the given block height.
This behaves the same as Self::get_block, except that a missing block will cause the function to
return Ok(None) instead of an error.
Sourcepub fn get_blocks(&self, heights: Range<u32>) -> Result<Vec<Block<N>>>
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.
Sourcepub fn get_block_by_hash(&self, block_hash: &N::BlockHash) -> Result<Block<N>>
pub fn get_block_by_hash(&self, block_hash: &N::BlockHash) -> Result<Block<N>>
Returns the block for the given block hash.
Sourcepub fn try_get_block_by_hash(
&self,
block_hash: &N::BlockHash,
) -> Result<Option<Block<N>>>
pub fn try_get_block_by_hash( &self, block_hash: &N::BlockHash, ) -> Result<Option<Block<N>>>
Returns the block for the given block hash.
This behaves the same as Self::get_block_by_hash, except that a missing block will cause the function to
return Ok(None) instead of an error.
Sourcepub fn get_height(&self, block_hash: &N::BlockHash) -> Result<u32>
pub fn get_height(&self, block_hash: &N::BlockHash) -> Result<u32>
Returns the block height for the given block hash.
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_aborted_transaction_ids(
&self,
height: u32,
) -> Result<Vec<N::TransactionID>>
pub fn get_aborted_transaction_ids( &self, height: u32, ) -> Result<Vec<N::TransactionID>>
Returns the aborted transaction IDs 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_confirmed_transaction(
&self,
transaction_id: N::TransactionID,
) -> Result<ConfirmedTransaction<N>>
pub fn get_confirmed_transaction( &self, transaction_id: N::TransactionID, ) -> Result<ConfirmedTransaction<N>>
Returns the confirmed transaction for the given transaction ID.
Sourcepub fn get_unconfirmed_transaction(
&self,
transaction_id: &N::TransactionID,
) -> Result<Transaction<N>>
pub fn get_unconfirmed_transaction( &self, transaction_id: &N::TransactionID, ) -> Result<Transaction<N>>
Returns the unconfirmed transaction for the given transaction ID.
Sourcepub fn get_latest_edition_for_program(
&self,
program_id: &ProgramID<N>,
) -> Result<u16>
pub fn get_latest_edition_for_program( &self, program_id: &ProgramID<N>, ) -> Result<u16>
Returns the latest edition for the given program ID.
Sourcepub fn get_program(&self, program_id: ProgramID<N>) -> Result<Program<N>>
pub fn get_program(&self, program_id: ProgramID<N>) -> Result<Program<N>>
Returns the latest program for the given program ID.
Sourcepub fn get_program_for_edition(
&self,
program_id: ProgramID<N>,
edition: u16,
) -> Result<Program<N>>
pub fn get_program_for_edition( &self, program_id: ProgramID<N>, edition: u16, ) -> Result<Program<N>>
Returns the program for the given program ID and edition.
Sourcepub fn try_get_program_for_edition(
&self,
program_id: &ProgramID<N>,
edition: u16,
) -> Result<Option<Program<N>>>
pub fn try_get_program_for_edition( &self, program_id: &ProgramID<N>, edition: u16, ) -> Result<Option<Program<N>>>
Returns the program for the given program ID and edition,
or None if no program of this ID and edition exists.
Sourcepub fn get_solutions(&self, height: u32) -> Result<Solutions<N>>
pub fn get_solutions(&self, height: u32) -> Result<Solutions<N>>
Returns the block solutions for the given block height.
Sourcepub fn get_solution(&self, solution_id: &SolutionID<N>) -> Result<Solution<N>>
pub fn get_solution(&self, solution_id: &SolutionID<N>) -> Result<Solution<N>>
Returns the solution for the given solution ID.
Returns the block authority for the given block height.
Sourcepub fn get_batch_certificate(
&self,
certificate_id: &Field<N>,
) -> Result<Option<BatchCertificate<N>>>
pub fn get_batch_certificate( &self, certificate_id: &Field<N>, ) -> Result<Option<BatchCertificate<N>>>
Returns the batch certificate for the given certificate ID.
Sourcepub fn get_delegators_for_validator(
&self,
validator: &Address<N>,
) -> Result<Vec<Address<N>>>
pub fn get_delegators_for_validator( &self, validator: &Address<N>, ) -> Result<Vec<Address<N>>>
Returns the delegators for the given validator.
Sourcepub fn get_bonded_amount(&self, address: &Address<N>) -> Result<u64>
pub fn get_bonded_amount(&self, address: &Address<N>) -> Result<u64>
Returns the amount of microcredits that the given address has bonded.
Source§impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
Sourcepub fn num_remaining_solutions(
&self,
prover_address: &Address<N>,
additional_solutions_in_block: u64,
) -> u64
pub fn num_remaining_solutions( &self, prover_address: &Address<N>, additional_solutions_in_block: u64, ) -> u64
Returns the number of remaining solutions a prover can submit in the current epoch.
Sourcepub fn is_solution_limit_reached(
&self,
prover_address: &Address<N>,
additional_solutions_in_block: u64,
) -> bool
pub fn is_solution_limit_reached( &self, prover_address: &Address<N>, additional_solutions_in_block: u64, ) -> bool
Returns true if the given prover address has reached their solution limit for the current epoch.
Source§impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
Sourcepub fn state_roots(&self) -> impl '_ + Iterator<Item = Cow<'_, N::StateRoot>>
pub fn state_roots(&self) -> impl '_ + Iterator<Item = Cow<'_, N::StateRoot>>
Returns an iterator over the state roots, for all blocks in self.
Sourcepub fn solution_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, SolutionID<N>>>
pub fn solution_ids(&self) -> impl '_ + Iterator<Item = Cow<'_, SolutionID<N>>>
Returns an iterator over the solution IDs, for all blocks 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 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 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.
Source§impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
Sourcepub fn load(genesis_block: Block<N>, storage_mode: StorageMode) -> Result<Self>
pub fn load(genesis_block: Block<N>, storage_mode: StorageMode) -> Result<Self>
Loads the ledger from storage.
Sourcepub fn load_unchecked(
genesis_block: Block<N>,
storage_mode: StorageMode,
) -> Result<Self>
pub fn load_unchecked( genesis_block: Block<N>, storage_mode: StorageMode, ) -> Result<Self>
Loads the ledger from storage, without performing integrity checks.
Source§impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
Sourcepub fn load_epoch_provers(&self) -> IndexMap<Address<N>, u32>
pub fn load_epoch_provers(&self) -> IndexMap<Address<N>, u32>
Loads the provers and the number of solutions they have submitted for the current epoch.
Sourcepub fn block_cache_size(&self) -> Option<u32>
pub fn block_cache_size(&self) -> Option<u32>
Returns the size of the block cache (or None if the block cache is not enabled).
Sourcepub fn epoch_provers(&self) -> Arc<RwLock<IndexMap<Address<N>, u32>>> ⓘ
pub fn epoch_provers(&self) -> Arc<RwLock<IndexMap<Address<N>, u32>>> ⓘ
Returns the provers and the number of solutions they have submitted for the current epoch.
Sourcepub fn latest_committee(&self) -> Result<Committee<N>>
pub fn latest_committee(&self) -> Result<Committee<N>>
Returns the latest committee, i.e. the committee resulting from all the on-chain staking activity.
Sourcepub fn latest_state_root(&self) -> N::StateRoot
pub fn latest_state_root(&self) -> N::StateRoot
Returns the latest state root.
Sourcepub fn latest_epoch_number(&self) -> u32
pub fn latest_epoch_number(&self) -> u32
Returns the latest epoch number.
Sourcepub fn latest_epoch_hash(&self) -> Result<N::BlockHash>
pub fn latest_epoch_hash(&self) -> Result<N::BlockHash>
Returns the latest epoch hash.
Sourcepub fn latest_block(&self) -> Block<N>
pub fn latest_block(&self) -> Block<N>
Returns the latest block.
Sourcepub fn latest_round(&self) -> u64
pub fn latest_round(&self) -> u64
Returns the latest round number.
Sourcepub fn latest_height(&self) -> u32
pub fn latest_height(&self) -> u32
Returns the latest block height.
Sourcepub fn latest_hash(&self) -> N::BlockHash
pub fn latest_hash(&self) -> N::BlockHash
Returns the latest block hash.
Sourcepub fn latest_header(&self) -> Header<N>
pub fn latest_header(&self) -> Header<N>
Returns the latest block header.
Sourcepub fn latest_cumulative_weight(&self) -> u128
pub fn latest_cumulative_weight(&self) -> u128
Returns the latest block cumulative weight.
Sourcepub fn latest_cumulative_proof_target(&self) -> u128
pub fn latest_cumulative_proof_target(&self) -> u128
Returns the latest block cumulative proof target.
Sourcepub fn latest_solutions_root(&self) -> Field<N>
pub fn latest_solutions_root(&self) -> Field<N>
Returns the latest block solutions root.
Sourcepub fn latest_coinbase_target(&self) -> u64
pub fn latest_coinbase_target(&self) -> u64
Returns the latest block coinbase target.
Sourcepub fn latest_proof_target(&self) -> u64
pub fn latest_proof_target(&self) -> u64
Returns the latest block proof target.
Sourcepub fn last_coinbase_target(&self) -> u64
pub fn last_coinbase_target(&self) -> u64
Returns the last coinbase target.
Sourcepub fn last_coinbase_timestamp(&self) -> i64
pub fn last_coinbase_timestamp(&self) -> i64
Returns the last coinbase timestamp.
Sourcepub fn latest_timestamp(&self) -> i64
pub fn latest_timestamp(&self) -> i64
Returns the latest block timestamp.
Sourcepub fn latest_transactions(&self) -> Transactions<N>
pub fn latest_transactions(&self) -> Transactions<N>
Returns the latest block transactions.
Source§impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
impl<N: Network, C: ConsensusStorage<N>> Ledger<N, C>
Sourcepub fn find_unspent_credits_records(
&self,
view_key: &ViewKey<N>,
) -> Result<RecordMap<N>>
pub fn find_unspent_credits_records( &self, view_key: &ViewKey<N>, ) -> Result<RecordMap<N>>
Returns the unspent credits.aleo records.
Sourcepub fn create_deploy<R: Rng + CryptoRng>(
&self,
private_key: &PrivateKey<N>,
program: &Program<N>,
priority_fee_in_microcredits: u64,
query: Option<&dyn QueryTrait<N>>,
rng: &mut R,
) -> Result<Transaction<N>>
pub fn create_deploy<R: Rng + CryptoRng>( &self, private_key: &PrivateKey<N>, program: &Program<N>, priority_fee_in_microcredits: u64, query: Option<&dyn QueryTrait<N>>, rng: &mut R, ) -> Result<Transaction<N>>
Creates a deploy transaction.
The priority_fee_in_microcredits is an additional fee on top of the deployment fee.
Sourcepub fn create_transfer<R: Rng + CryptoRng>(
&self,
private_key: &PrivateKey<N>,
to: Address<N>,
amount_in_microcredits: u64,
priority_fee_in_microcredits: u64,
query: Option<&dyn QueryTrait<N>>,
rng: &mut R,
) -> Result<Transaction<N>>
pub fn create_transfer<R: Rng + CryptoRng>( &self, private_key: &PrivateKey<N>, to: Address<N>, amount_in_microcredits: u64, priority_fee_in_microcredits: u64, query: Option<&dyn QueryTrait<N>>, rng: &mut R, ) -> Result<Transaction<N>>
Creates a transfer transaction.
The priority_fee_in_microcredits is an additional fee on top of the execution fee.
Trait Implementations§
Auto Trait Implementations§
impl<N, C> Freeze for Ledger<N, C>
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>
impl<N, C> UnsafeUnpin for Ledger<N, C>
impl<N, C> !UnwindSafe for Ledger<N, C>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more