From 6baab92ab543c85f80e7fa570654dee25db92c33 Mon Sep 17 00:00:00 2001 From: Brooks Date: Fri, 20 Jan 2023 13:38:41 -0500 Subject: [PATCH] Refactors calculate_capitalization() (#29790) --- runtime/src/accounts.rs | 32 ++------------------------------ runtime/src/bank.rs | 30 +++++++++++++++++++++--------- 2 files changed, 23 insertions(+), 39 deletions(-) diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index 285e0ba02..9a7ffbde1 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -4,8 +4,8 @@ use { account_rent_state::{check_rent_state_with_account, RentState}, accounts_db::{ AccountShrinkThreshold, AccountsAddRootTiming, AccountsDb, AccountsDbConfig, - BankHashInfo, CalcAccountsHashDataSource, IncludeSlotInHash, LoadHint, LoadedAccount, - ScanStorageResult, ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, ACCOUNTS_DB_CONFIG_FOR_TESTING, + BankHashInfo, IncludeSlotInHash, LoadHint, LoadedAccount, ScanStorageResult, + ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, ACCOUNTS_DB_CONFIG_FOR_TESTING, }, accounts_index::{ AccountSecondaryIndexes, IndexKey, ScanConfig, ScanError, ScanResult, ZeroLamport, @@ -761,34 +761,6 @@ impl Accounts { .collect()) } - /// only called at startup vs steady-state runtime - pub fn calculate_capitalization( - &self, - ancestors: &Ancestors, - slot: Slot, - debug_verify: bool, - epoch_schedule: &EpochSchedule, - rent_collector: &RentCollector, - data_source: CalcAccountsHashDataSource, - ) -> u64 { - let is_startup = true; - self.accounts_db - .verify_accounts_hash_in_bg - .wait_for_complete(); - self.accounts_db - .update_accounts_hash( - data_source, - debug_verify, - slot, - ancestors, - None, - epoch_schedule, - rent_collector, - is_startup, - ) - .1 - } - /// Only called from startup or test code. #[must_use] #[allow(clippy::too_many_arguments)] diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index 2849aacde..c43550c5e 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -6899,15 +6899,27 @@ impl Bank { /// only called from ledger-tool or tests fn calculate_capitalization(&self, debug_verify: bool) -> u64 { - self.rc.accounts.calculate_capitalization( - &self.ancestors, - self.slot(), - debug_verify, - self.epoch_schedule(), - &self.rent_collector, - // we have to use the index since the slot could be in the write cache still - CalcAccountsHashDataSource::IndexForTests, - ) + let is_startup = true; + self.rc + .accounts + .accounts_db + .verify_accounts_hash_in_bg + .wait_for_complete(); + self.rc + .accounts + .accounts_db + .update_accounts_hash( + // we have to use the index since the slot could be in the write cache still + CalcAccountsHashDataSource::IndexForTests, + debug_verify, + self.slot(), + &self.ancestors, + None, + self.epoch_schedule(), + &self.rent_collector, + is_startup, + ) + .1 } /// only called from tests or ledger tool