Trait snapps_txn_reference_impl::ledger::Ledger [−][src]
pub trait Ledger {
type Index;
fn root_hash(ledger: &Self) -> Hash;
fn find_index(ledger: &Self, public_key: PublicKey) -> Option<Self::Index>;
fn next_index(ledger: &Self) -> Self::Index;
fn get_account<'a>(ledger: &Self, index: &Self::Index) -> Account<'a>;
fn set_account(ledger: &mut Self, index: &Self::Index, account: Account<'_>);
}
Expand description
Interface for ledgers
Associated Types
Required methods
Find the position in the ledger for the account with public key public_key
.
If there is no account in the ledger with public key public_key
, find_index(public_key)
must return None
.
fn next_index(ledger: &Self) -> Self::Index
fn next_index(ledger: &Self) -> Self::Index
Return the next unused index in the ledger.
If there are no unused indexes remaining in the ledger, this function must raise an error that aborts the transaction as invalid.
fn get_account<'a>(ledger: &Self, index: &Self::Index) -> Account<'a>
fn get_account<'a>(ledger: &Self, index: &Self::Index) -> Account<'a>
Return the account in the ledger at the given index.
fn set_account(ledger: &mut Self, index: &Self::Index, account: Account<'_>)
fn set_account(ledger: &mut Self, index: &Self::Index, account: Account<'_>)
Set the contents of the account in the ledger at the specified index.