Skip to content

Commit

Permalink
remove FoundStoredAccount.account_size (solana-labs#26460)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffwashington authored Jul 7, 2022
1 parent 3b759bc commit d9eee72
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 17 deletions.
9 changes: 2 additions & 7 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,6 @@ pub struct AccountsDbConfig {
pub struct FoundStoredAccount<'a> {
pub account: StoredAccountMeta<'a>,
pub store_id: AppendVecId,
pub account_size: usize,
}

#[cfg(not(test))]
Expand Down Expand Up @@ -3081,7 +3080,7 @@ impl AccountsDb {
dead += 1;
} else {
alive_accounts.push(pair);
alive_total += stored_account.account_size;
alive_total += stored_account.account.stored_size;
alive += 1;
}
}
Expand Down Expand Up @@ -3116,11 +3115,7 @@ impl AccountsDb {
original_bytes += store.total_bytes();
let store_id = store.append_vec_id();
AppendVecAccountsIter::new(&store.accounts).for_each(|account| {
let new_entry = FoundStoredAccount {
account_size: account.stored_size,
account,
store_id,
};
let new_entry = FoundStoredAccount { account, store_id };
match stored_accounts.entry(new_entry.account.meta.pubkey) {
Entry::Occupied(mut occupied_entry) => {
if new_entry.account.meta.write_version
Expand Down
12 changes: 3 additions & 9 deletions runtime/src/ancient_append_vecs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ impl<'a> AccountsToStore<'a> {
// index of the first account that doesn't fit in the current append vec
let mut index_first_item_overflow = num_accounts; // assume all fit
stored_accounts.iter().for_each(|account| {
let account_size = account.1.account_size as u64;
let account_size = account.1.account.stored_size as u64;
if available_bytes >= account_size {
available_bytes = available_bytes.saturating_sub(account_size);
} else if index_first_item_overflow == num_accounts {
Expand Down Expand Up @@ -147,7 +147,6 @@ pub mod tests {
rent_epoch: 0,
};
let offset = 3;
let stored_size = 4;
let hash = Hash::new(&[2; 32]);
let stored_meta = StoredMeta {
/// global write version
Expand All @@ -162,15 +161,10 @@ pub mod tests {
account_meta: &account_meta,
data: account.data(),
offset,
stored_size,
stored_size: account_size,
hash: &hash,
};
// let account = StoredAccountMeta::new();
let found = FoundStoredAccount {
account,
store_id,
account_size,
};
let found = FoundStoredAccount { account, store_id };
let item = (pubkey, found);
let map = vec![&item];
for (selector, available_bytes) in [
Expand Down
2 changes: 1 addition & 1 deletion runtime/src/snapshot_minimizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ impl<'a> SnapshotMinimizer<'a> {
let mut purge_pubkeys = Vec::with_capacity(CHUNK_SIZE);
chunk.iter().for_each(|(pubkey, account)| {
if self.minimized_account_set.contains(pubkey) {
chunk_bytes += account.account_size;
chunk_bytes += account.account.stored_size;
keep_accounts.push((pubkey, account));
} else if self
.accounts_db()
Expand Down

0 comments on commit d9eee72

Please sign in to comment.