From c9e0bde407bd3983b7e10e4870ef94e316b44aaa Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Mon, 13 Dec 2021 10:10:06 -0600 Subject: [PATCH] AcctIdx: AccountInfo::stored_size private (#21821) --- runtime/src/account_info.rs | 6 +++++- runtime/src/accounts_db.rs | 4 ++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/runtime/src/account_info.rs b/runtime/src/account_info.rs index bb373046f9..eb4a9d5ea3 100644 --- a/runtime/src/account_info.rs +++ b/runtime/src/account_info.rs @@ -10,7 +10,7 @@ pub struct AccountInfo { /// needed to track shrink candidacy in bytes. Used to update the number /// of alive bytes in an AppendVec as newer slots purge outdated entries - pub stored_size: usize, + stored_size: usize, /// lamports in the account used when squashing kept for optimization /// purposes to remove accounts with zero balance. @@ -32,4 +32,8 @@ impl AccountInfo { lamports, } } + + pub fn stored_size(&self) -> usize { + self.stored_size + } } diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 671b6d35f9..45c83fcca4 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -6016,7 +6016,7 @@ impl AccountsDb { "AccountDB::accounts_index corrupted. Storage pointed to: {}, expected: {}, should only point to one slot", store.slot(), *slot ); - let count = store.remove_account(account_info.stored_size, reset_accounts); + let count = store.remove_account(account_info.stored_size(), reset_accounts); if count == 0 { self.dirty_stores .insert((*slot, store.append_vec_id()), store.clone()); @@ -11852,7 +11852,7 @@ pub mod tests { locked_entry.slot_list()[0] }) .unwrap(); - let removed_data_size = account_info.1.stored_size; + let removed_data_size = account_info.1.stored_size(); // Fetching the account from storage should return the same // stored size as in the index. assert_eq!(removed_data_size, account.stored_size);