Refactors calculate_capitalization() (#29790)
This commit is contained in:
parent
8c793da7d0
commit
6baab92ab5
|
@ -4,8 +4,8 @@ use {
|
||||||
account_rent_state::{check_rent_state_with_account, RentState},
|
account_rent_state::{check_rent_state_with_account, RentState},
|
||||||
accounts_db::{
|
accounts_db::{
|
||||||
AccountShrinkThreshold, AccountsAddRootTiming, AccountsDb, AccountsDbConfig,
|
AccountShrinkThreshold, AccountsAddRootTiming, AccountsDb, AccountsDbConfig,
|
||||||
BankHashInfo, CalcAccountsHashDataSource, IncludeSlotInHash, LoadHint, LoadedAccount,
|
BankHashInfo, IncludeSlotInHash, LoadHint, LoadedAccount, ScanStorageResult,
|
||||||
ScanStorageResult, ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, ACCOUNTS_DB_CONFIG_FOR_TESTING,
|
ACCOUNTS_DB_CONFIG_FOR_BENCHMARKS, ACCOUNTS_DB_CONFIG_FOR_TESTING,
|
||||||
},
|
},
|
||||||
accounts_index::{
|
accounts_index::{
|
||||||
AccountSecondaryIndexes, IndexKey, ScanConfig, ScanError, ScanResult, ZeroLamport,
|
AccountSecondaryIndexes, IndexKey, ScanConfig, ScanError, ScanResult, ZeroLamport,
|
||||||
|
@ -761,34 +761,6 @@ impl Accounts {
|
||||||
.collect())
|
.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.
|
/// Only called from startup or test code.
|
||||||
#[must_use]
|
#[must_use]
|
||||||
#[allow(clippy::too_many_arguments)]
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
|
|
@ -6899,15 +6899,27 @@ impl Bank {
|
||||||
|
|
||||||
/// only called from ledger-tool or tests
|
/// only called from ledger-tool or tests
|
||||||
fn calculate_capitalization(&self, debug_verify: bool) -> u64 {
|
fn calculate_capitalization(&self, debug_verify: bool) -> u64 {
|
||||||
self.rc.accounts.calculate_capitalization(
|
let is_startup = true;
|
||||||
&self.ancestors,
|
self.rc
|
||||||
self.slot(),
|
.accounts
|
||||||
debug_verify,
|
.accounts_db
|
||||||
self.epoch_schedule(),
|
.verify_accounts_hash_in_bg
|
||||||
&self.rent_collector,
|
.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
|
// we have to use the index since the slot could be in the write cache still
|
||||||
CalcAccountsHashDataSource::IndexForTests,
|
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
|
/// only called from tests or ledger tool
|
||||||
|
|
Loading…
Reference in New Issue