Trait BaseLedger

Source
pub trait BaseLedger {
Show 38 methods // Required methods fn to_list(&self) -> Vec<Account>; fn iter<F>(&self, fun: F) where F: FnMut(&Account); fn fold<B, F>(&self, init: B, fun: F) -> B where F: FnMut(B, &Account) -> B; fn fold_with_ignored_accounts<B, F>( &self, ignoreds: HashSet<AccountId>, init: B, fun: F, ) -> B where F: FnMut(B, &Account) -> B; fn fold_until<B, F>(&self, init: B, fun: F) -> B where F: FnMut(B, &Account) -> ControlFlow<B, B>; fn accounts(&self) -> HashSet<AccountId>; fn token_owner(&self, token_id: TokenId) -> Option<AccountId>; fn tokens(&self, public_key: CompressedPubKey) -> HashSet<TokenId>; fn location_of_account(&self, account_id: &AccountId) -> Option<Address>; fn location_of_account_batch( &self, account_ids: &[AccountId], ) -> Vec<(AccountId, Option<Address>)>; fn get_or_create_account( &mut self, account_id: AccountId, account: Account, ) -> Result<GetOrCreated, DatabaseError>; fn close(&self); fn last_filled(&self) -> Option<Address>; fn get_uuid(&self) -> Uuid; fn get_directory(&self) -> Option<PathBuf>; fn get(&self, addr: Address) -> Option<Box<Account>>; fn get_batch( &self, addr: &[Address], ) -> Vec<(Address, Option<Box<Account>>)>; fn set(&mut self, addr: Address, account: Box<Account>); fn set_batch(&mut self, list: &[(Address, Box<Account>)]); fn get_at_index(&self, index: AccountIndex) -> Option<Box<Account>>; fn set_at_index( &mut self, index: AccountIndex, account: Box<Account>, ) -> Result<(), ()>; fn index_of_account(&self, account_id: AccountId) -> Option<AccountIndex>; fn merkle_root(&mut self) -> Fp; fn merkle_path(&mut self, addr: Address) -> Vec<MerklePath>; fn merkle_path_at_index(&mut self, index: AccountIndex) -> Vec<MerklePath>; fn remove_accounts(&mut self, ids: &[AccountId]); fn detached_signal(&mut self); fn depth(&self) -> u8; fn num_accounts(&self) -> usize; fn merkle_path_at_addr(&mut self, addr: Address) -> Vec<MerklePath>; fn get_inner_hash_at_addr(&mut self, addr: Address) -> Result<Fp, String>; fn set_inner_hash_at_addr( &mut self, addr: Address, hash: Fp, ) -> Result<(), ()>; fn set_all_accounts_rooted_at( &mut self, addr: Address, accounts: &[Box<Account>], ) -> Result<(), ()>; fn get_all_accounts_rooted_at( &self, addr: Address, ) -> Option<Vec<(Address, Box<Account>)>>; fn make_space_for(&mut self, space: usize); fn get_account_hash(&mut self, account_index: AccountIndex) -> Option<Fp>; fn commit(&mut self); // Provided method fn set_batch_accounts(&mut self, list: &[(Address, Box<Account>)]) { ... }
}

Required Methods§

Source

fn to_list(&self) -> Vec<Account>

list of accounts in the ledger

Source

fn iter<F>(&self, fun: F)
where F: FnMut(&Account),

iterate over all indexes and accounts

Source

fn fold<B, F>(&self, init: B, fun: F) -> B
where F: FnMut(B, &Account) -> B,

fold over accounts in the ledger, passing the Merkle address

Source

fn fold_with_ignored_accounts<B, F>( &self, ignoreds: HashSet<AccountId>, init: B, fun: F, ) -> B
where F: FnMut(B, &Account) -> B,

the set of account_ids are ledger elements to skip during the fold, because they’re in a mask

Source

fn fold_until<B, F>(&self, init: B, fun: F) -> B
where F: FnMut(B, &Account) -> ControlFlow<B, B>,

fold until fun returns ControlFlow::Stop

Source

fn accounts(&self) -> HashSet<AccountId>

set of account ids associated with accounts

Source

fn token_owner(&self, token_id: TokenId) -> Option<AccountId>

Get the account id that owns a token.

Source

fn tokens(&self, public_key: CompressedPubKey) -> HashSet<TokenId>

Get all of the tokens for which a public key has accounts.

Source

fn location_of_account(&self, account_id: &AccountId) -> Option<Address>

Source

fn location_of_account_batch( &self, account_ids: &[AccountId], ) -> Vec<(AccountId, Option<Address>)>

Source

fn get_or_create_account( &mut self, account_id: AccountId, account: Account, ) -> Result<GetOrCreated, DatabaseError>

This may return an error if the ledger is full.

Source

fn close(&self)

the ledger should not be used after calling close

Source

fn last_filled(&self) -> Option<Address>

for account locations in the ledger, the last (rightmost) filled location

Source

fn get_uuid(&self) -> Uuid

Source

fn get_directory(&self) -> Option<PathBuf>

return Some directory for ledgers that use a file system, else None

Source

fn get(&self, addr: Address) -> Option<Box<Account>>

Source

fn get_batch(&self, addr: &[Address]) -> Vec<(Address, Option<Box<Account>>)>

Source

fn set(&mut self, addr: Address, account: Box<Account>)

Source

fn set_batch(&mut self, list: &[(Address, Box<Account>)])

Source

fn get_at_index(&self, index: AccountIndex) -> Option<Box<Account>>

Source

fn set_at_index( &mut self, index: AccountIndex, account: Box<Account>, ) -> Result<(), ()>

Source

fn index_of_account(&self, account_id: AccountId) -> Option<AccountIndex>

Source

fn merkle_root(&mut self) -> Fp

meant to be a fast operation: the root hash is stored, rather than calculated dynamically

Source

fn merkle_path(&mut self, addr: Address) -> Vec<MerklePath>

Source

fn merkle_path_at_index(&mut self, index: AccountIndex) -> Vec<MerklePath>

Source

fn remove_accounts(&mut self, ids: &[AccountId])

Source

fn detached_signal(&mut self)

Triggers when the ledger has been detached and should no longer be accessed.

Source

fn depth(&self) -> u8

Source

fn num_accounts(&self) -> usize

Source

fn merkle_path_at_addr(&mut self, addr: Address) -> Vec<MerklePath>

Source

fn get_inner_hash_at_addr(&mut self, addr: Address) -> Result<Fp, String>

Source

fn set_inner_hash_at_addr(&mut self, addr: Address, hash: Fp) -> Result<(), ()>

Source

fn set_all_accounts_rooted_at( &mut self, addr: Address, accounts: &[Box<Account>], ) -> Result<(), ()>

Source

fn get_all_accounts_rooted_at( &self, addr: Address, ) -> Option<Vec<(Address, Box<Account>)>>

Get all of the accounts that are in a subtree of the underlying Merkle tree rooted at address. The accounts are ordered by their addresses.

Source

fn make_space_for(&mut self, space: usize)

Source

fn get_account_hash(&mut self, account_index: AccountIndex) -> Option<Fp>

Source

fn commit(&mut self)

Used on mask only, has no effect with other implementation Required for LedgerIntf on masks

Provided Methods§

Source

fn set_batch_accounts(&mut self, list: &[(Address, Box<Account>)])

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§