pub struct AccountsToStore<'a> {
accounts: &'a [&'a StoredAccountMeta<'a>],
index_first_item_overflow: usize,
pub slot: Slot,
}
Expand description
reference a set of accounts to store The accounts may have to be split between 2 storages (primary and overflow) if there is not enough room in the primary storage. The ‘store’ functions need data stored in a slice of specific type. We need 1-2 of these slices constructed based on available bytes and individual account sizes. The slice arithmetic across both hashes and account data gets messy. So, this struct abstracts that.
Fields§
§accounts: &'a [&'a StoredAccountMeta<'a>]
§index_first_item_overflow: usize
if ‘accounts’ contains more items than can be contained in the primary storage, then we have to split these accounts. ‘index_first_item_overflow’ specifies the index of the first item in ‘accounts’ that will go into the overflow storage
slot: Slot
Implementations§
source§impl<'a> AccountsToStore<'a>
impl<'a> AccountsToStore<'a>
sourcepub fn new(
available_bytes: u64,
accounts: &'a [&'a StoredAccountMeta<'a>],
alive_total_bytes: usize,
slot: Slot
) -> Self
pub fn new( available_bytes: u64, accounts: &'a [&'a StoredAccountMeta<'a>], alive_total_bytes: usize, slot: Slot ) -> Self
break ‘stored_accounts’ into primary and overflow available_bytes: how many bytes remain in the primary storage. Excess accounts will be directed to an overflow storage
sourcepub fn has_overflow(&self) -> bool
pub fn has_overflow(&self) -> bool
true if a request to ‘get’ ‘Overflow’ would return accounts & hashes
sourcepub fn get(&self, storage: StorageSelector) -> &[&'a StoredAccountMeta<'a>]
pub fn get(&self, storage: StorageSelector) -> &[&'a StoredAccountMeta<'a>]
get the accounts to store in the given ‘storage’