solana_accounts_db::storable_accounts

Trait StorableAccounts

source
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§

source

fn pubkey(&self, index: usize) -> &Pubkey

pubkey at ‘index’

source

fn account(&self, index: usize) -> &T

account at ‘index’

source

fn slot(&self, index: usize) -> Slot

source

fn target_slot(&self) -> Slot

slot that all accounts are to be written to

source

fn len(&self) -> usize

§accounts to write

Provided Methods§

source

fn account_default_if_zero_lamport(&self, index: usize) -> Option<&T>

None if account is zero lamports

source

fn is_empty(&self) -> bool

true if no accounts to write

source

fn contains_multiple_slots(&self) -> bool

are there accounts from multiple slots only used for an assert

source

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.

source

fn hash(&self, _index: usize) -> &AccountHash

return hash for account at ‘index’ Should only be called if ‘has_hash_and_write_version’ = true

source

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>])

source§

fn pubkey(&self, index: usize) -> &Pubkey

source§

fn account(&self, index: usize) -> &StoredAccountMeta<'a>

source§

fn slot(&self, _index: usize) -> Slot

source§

fn target_slot(&self) -> Slot

source§

fn len(&self) -> usize

source§

fn has_hash_and_write_version(&self) -> bool

source§

fn hash(&self, index: usize) -> &AccountHash

source§

fn write_version(&self, index: usize) -> u64

source§

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

source§

fn pubkey(&self, index: usize) -> &Pubkey

source§

fn account(&self, index: usize) -> &StoredAccountMeta<'a>

source§

fn slot(&self, _index: usize) -> Slot

source§

fn target_slot(&self) -> Slot

source§

fn len(&self) -> usize

source§

fn has_hash_and_write_version(&self) -> bool

source§

fn hash(&self, index: usize) -> &AccountHash

source§

fn write_version(&self, index: usize) -> u64

source§

impl<'a> StorableAccounts<'a, AccountSharedData> for (Slot, &'a [StakeReward])

allow StakeReward to be passed to StoreAccounts directly without copies or vec construction

source§

fn pubkey(&self, index: usize) -> &Pubkey

source§

fn account(&self, index: usize) -> &AccountSharedData

source§

fn slot(&self, _index: usize) -> Slot

source§

fn target_slot(&self) -> Slot

source§

fn len(&self) -> usize

source§

impl<'a, T: ReadableAccount + Sync> StorableAccounts<'a, T> for (Slot, &'a [&'a (Pubkey, T)])

source§

fn pubkey(&self, index: usize) -> &Pubkey

source§

fn account(&self, index: usize) -> &T

source§

fn slot(&self, _index: usize) -> Slot

source§

fn target_slot(&self) -> Slot

source§

fn len(&self) -> usize

source§

impl<'a, T: ReadableAccount + Sync> StorableAccounts<'a, T> for (Slot, &'a [(&'a Pubkey, &'a T)])

source§

fn pubkey(&self, index: usize) -> &Pubkey

source§

fn account(&self, index: usize) -> &T

source§

fn slot(&self, _index: usize) -> Slot

source§

fn target_slot(&self) -> Slot

source§

fn len(&self) -> usize

Implementors§