pub struct StorableAccountsWithHashesAndWriteVersions<'a: 'b, 'b, T: ReadableAccount + Sync + 'b, U: StorableAccounts<'a, T>, V: Borrow<Hash>> { /* private fields */ }Expand description
Goal is to eliminate copies and data reshaping given various code paths that store accounts. This struct contains what is needed to store accounts to a storage
- account & pubkey (StorableAccounts)
- hash per account (Maybe in StorableAccounts, otherwise has to be passed in separately)
- write version per account (Maybe in StorableAccounts, otherwise has to be passed in separately)
Implementations§
source§impl<'a: 'b, 'b, T: ReadableAccount + Sync + 'b, U: StorableAccounts<'a, T>, V: Borrow<Hash>> StorableAccountsWithHashesAndWriteVersions<'a, 'b, T, U, V>
impl<'a: 'b, 'b, T: ReadableAccount + Sync + 'b, U: StorableAccounts<'a, T>, V: Borrow<Hash>> StorableAccountsWithHashesAndWriteVersions<'a, 'b, T, U, V>
sourcepub fn new_with_hashes_and_write_versions(
accounts: &'b U,
hashes: Vec<V>,
write_versions: Vec<StoredMetaWriteVersion>
) -> Self
pub fn new_with_hashes_and_write_versions(
accounts: &'b U,
hashes: Vec<V>,
write_versions: Vec<StoredMetaWriteVersion>
) -> Self
used when accounts does NOT contains hash or write version In this case, hashes and write_versions have to be passed in separately and zipped together.
sourcepub fn write_version(&self, index: usize) -> u64
pub fn write_version(&self, index: usize) -> u64
write_version for the account at ‘index’
sourcepub fn account(&self, index: usize) -> Option<&T>
pub fn account(&self, index: usize) -> Option<&T>
None if account at index has lamports == 0 Otherwise, Some(account) This is the only way to access the account.