pub trait StorableAccounts<'a, T: ReadableAccount + Sync>: Sync {
// Required methods
fn pubkey(&self, index: usize) -> &Pubkey;
fn account(&self, index: usize) -> &T;
fn slot(&self, index: usize) -> Slot;
fn target_slot(&self) -> Slot;
fn len(&self) -> usize;
// Provided methods
fn account_default_if_zero_lamport(&self, index: usize) -> Option<&T> { ... }
fn is_empty(&self) -> bool { ... }
fn contains_multiple_slots(&self) -> bool { ... }
fn has_hash_and_write_version(&self) -> bool { ... }
fn hash(&self, _index: usize) -> &AccountHash { ... }
fn write_version(&self, _index: usize) -> u64 { ... }
}
Expand description
abstract access to pubkey, account, slot, target_slot of either: a. (slot, &[&Pubkey, &ReadableAccount]) b. (slot, &[&Pubkey, &ReadableAccount, Slot]) (we will use this later) This trait avoids having to allocate redundant data when there is a duplicated slot parameter. All legacy callers do not have a unique slot per account to store.
Required Methods§
fn slot(&self, index: usize) -> Slot
sourcefn target_slot(&self) -> Slot
fn target_slot(&self) -> Slot
slot that all accounts are to be written to
Provided Methods§
sourcefn account_default_if_zero_lamport(&self, index: usize) -> Option<&T>
fn account_default_if_zero_lamport(&self, index: usize) -> Option<&T>
None if account is zero lamports
sourcefn contains_multiple_slots(&self) -> bool
fn contains_multiple_slots(&self) -> bool
are there accounts from multiple slots only used for an assert
sourcefn has_hash_and_write_version(&self) -> bool
fn has_hash_and_write_version(&self) -> bool
true iff the impl can provide hash and write_version Otherwise, hash and write_version have to be provided separately to store functions.
sourcefn hash(&self, _index: usize) -> &AccountHash
fn hash(&self, _index: usize) -> &AccountHash
return hash for account at ‘index’ Should only be called if ‘has_hash_and_write_version’ = true
sourcefn write_version(&self, _index: usize) -> u64
fn write_version(&self, _index: usize) -> u64
return write_version for account at ‘index’ Should only be called if ‘has_hash_and_write_version’ = true
Implementations on Foreign Types§
source§impl<'a> StorableAccounts<'a, StoredAccountMeta<'a>> for (Slot, &'a [&'a StoredAccountMeta<'a>])
impl<'a> StorableAccounts<'a, StoredAccountMeta<'a>> for (Slot, &'a [&'a StoredAccountMeta<'a>])
fn pubkey(&self, index: usize) -> &Pubkey
fn account(&self, index: usize) -> &StoredAccountMeta<'a>
fn slot(&self, _index: usize) -> Slot
fn target_slot(&self) -> Slot
fn len(&self) -> usize
fn has_hash_and_write_version(&self) -> bool
fn hash(&self, index: usize) -> &AccountHash
fn write_version(&self, index: usize) -> u64
source§impl<'a> StorableAccounts<'a, StoredAccountMeta<'a>> for (Slot, &'a [&'a StoredAccountMeta<'a>], Slot)
impl<'a> StorableAccounts<'a, StoredAccountMeta<'a>> for (Slot, &'a [&'a StoredAccountMeta<'a>], Slot)
this tuple contains a single different source slot that applies to all accounts accounts are StoredAccountMeta
fn pubkey(&self, index: usize) -> &Pubkey
fn account(&self, index: usize) -> &StoredAccountMeta<'a>
fn slot(&self, _index: usize) -> Slot
fn target_slot(&self) -> Slot
fn len(&self) -> usize
fn has_hash_and_write_version(&self) -> bool
fn hash(&self, index: usize) -> &AccountHash
fn write_version(&self, index: usize) -> u64
allow StakeReward to be passed to StoreAccounts
directly without copies or vec construction