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§
Sourcefn fold<B, F>(&self, init: B, fun: F) -> B
fn fold<B, F>(&self, init: B, fun: F) -> B
fold over accounts in the ledger, passing the Merkle address
Sourcefn fold_with_ignored_accounts<B, F>(
&self,
ignoreds: HashSet<AccountId>,
init: B,
fun: F,
) -> B
fn fold_with_ignored_accounts<B, F>( &self, ignoreds: HashSet<AccountId>, init: B, fun: F, ) -> B
the set of account_id
s are ledger elements to skip during the fold,
because they’re in a mask
Sourcefn fold_until<B, F>(&self, init: B, fun: F) -> B
fn fold_until<B, F>(&self, init: B, fun: F) -> B
fold until fun
returns ControlFlow::Stop
Sourcefn token_owner(&self, token_id: TokenId) -> Option<AccountId>
fn token_owner(&self, token_id: TokenId) -> Option<AccountId>
Get the account id that owns a token.
Sourcefn tokens(&self, public_key: CompressedPubKey) -> HashSet<TokenId>
fn tokens(&self, public_key: CompressedPubKey) -> HashSet<TokenId>
Get all of the tokens for which a public key has accounts.
fn location_of_account(&self, account_id: &AccountId) -> Option<Address>
fn location_of_account_batch( &self, account_ids: &[AccountId], ) -> Vec<(AccountId, Option<Address>)>
Sourcefn get_or_create_account(
&mut self,
account_id: AccountId,
account: Account,
) -> Result<GetOrCreated, DatabaseError>
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.
Sourcefn last_filled(&self) -> Option<Address>
fn last_filled(&self) -> Option<Address>
for account locations in the ledger, the last (rightmost) filled location
fn get_uuid(&self) -> Uuid
Sourcefn get_directory(&self) -> Option<PathBuf>
fn get_directory(&self) -> Option<PathBuf>
return Some directory
for ledgers that use a file system, else None
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>
Sourcefn merkle_root(&mut self) -> Fp
fn merkle_root(&mut self) -> Fp
meant to be a fast operation: the root hash is stored, rather than calculated dynamically
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])
Sourcefn detached_signal(&mut self)
fn detached_signal(&mut self)
Triggers when the ledger has been detached and should no longer be accessed.
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<(), ()>
Sourcefn get_all_accounts_rooted_at(
&self,
addr: Address,
) -> Option<Vec<(Address, Box<Account>)>>
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.
fn make_space_for(&mut self, space: usize)
fn get_account_hash(&mut self, account_index: AccountIndex) -> Option<Fp>
Provided Methods§
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.