From 5a613e9b6e2b5cadd2ae4374b607e9475a413f41 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" Date: Tue, 29 Mar 2022 22:05:47 -0500 Subject: [PATCH] use CalcAccountsHashConfig in calculate_accounts_hash (#23987) --- runtime/src/accounts_db.rs | 19 +++++++++++++------ runtime/src/sorted_storages.rs | 10 ++++++++++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index de48306e6c..df0bbe3424 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -5113,8 +5113,7 @@ impl AccountsDb { fn calculate_accounts_hash( &self, slot: Slot, - ancestors: &Ancestors, - check_hash: bool, // this will not be supported anymore + config: &CalcAccountsHashConfig<'_>, ) -> Result<(Hash, u64), BankHashVerificationError> { use BankHashVerificationError::*; let mut collect = Measure::start("collect"); @@ -5147,7 +5146,7 @@ impl AccountsDb { return None; } if let AccountIndexGetResult::Found(lock, index) = - self.accounts_index.get(pubkey, Some(ancestors), Some(slot)) + self.accounts_index.get(pubkey, config.ancestors, Some(slot)) { let (slot, account_info) = &lock.slot_list()[index]; if !account_info.is_zero_lamport() { @@ -5170,7 +5169,7 @@ impl AccountsDb { |loaded_account| { let loaded_hash = loaded_account.loaded_hash(); let balance = loaded_account.lamports(); - if check_hash && !self.is_filler_account(pubkey) { // this will not be supported anymore + if config.check_hash && !self.is_filler_account(pubkey) { // this will not be supported anymore let computed_hash = loaded_account.compute_hash(*slot, pubkey); if computed_hash != loaded_hash { @@ -5200,7 +5199,7 @@ impl AccountsDb { }).collect() }; - let hashes: Vec> = if check_hash { + let hashes: Vec> = if config.check_hash { get_hashes() } else { self.thread_pool_clean.install(get_hashes) @@ -5523,7 +5522,15 @@ impl AccountsDb { timings, ) } else { - self.calculate_accounts_hash(slot, ancestors, check_hash) + self.calculate_accounts_hash( + slot, + &CalcAccountsHashConfig { + storages: &SortedStorages::empty(), // unused + use_bg_thread_pool: !is_startup, + check_hash, + ancestors: Some(ancestors), + }, + ) } } diff --git a/runtime/src/sorted_storages.rs b/runtime/src/sorted_storages.rs index 51e514a9e6..ac8105d0f3 100644 --- a/runtime/src/sorted_storages.rs +++ b/runtime/src/sorted_storages.rs @@ -17,6 +17,16 @@ pub struct SortedStorages<'a> { } impl<'a> SortedStorages<'a> { + /// containing nothing + pub fn empty() -> Self { + SortedStorages { + range: Range::default(), + storages: Vec::default(), + slot_count: 0, + storage_count: 0, + } + } + /// primary method of retreiving (Slot, SnapshotStorage) pub fn iter_range(&'a self, range: R) -> SortedStoragesIter<'a> where