HashCalc uses self.accounts_cache (#23890)

This commit is contained in:
Jeff Washington (jwash) 2022-03-24 10:34:28 -05:00 committed by GitHub
parent f2aea3b7c7
commit 5b916961b5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 14 deletions

View File

@ -119,7 +119,7 @@ impl AccountsHashVerifier {
use_bg_thread_pool: true,
stats: HashStats::default(),
check_hash: false,
accounts_cache_and_ancestors: None,
ancestors: None,
})
.unwrap();

View File

@ -5492,14 +5492,14 @@ impl AccountsDb {
is_startup: bool,
) -> Result<(Hash, u64), BankHashVerificationError> {
if !use_index {
let accounts_cache_and_ancestors = if can_cached_slot_be_unflushed {
Some((&self.accounts_cache, ancestors))
let ancestors = if can_cached_slot_be_unflushed {
Some(ancestors)
} else {
None
};
let mut collect_time = Measure::start("collect");
let (combined_maps, slots) = self.get_snapshot_storages(slot, None, Some(ancestors));
let (combined_maps, slots) = self.get_snapshot_storages(slot, None, ancestors);
collect_time.stop();
let mut sort_time = Measure::start("sort_storages");
@ -5525,7 +5525,7 @@ impl AccountsDb {
use_bg_thread_pool: !is_startup,
stats: timings,
check_hash,
accounts_cache_and_ancestors,
ancestors,
})
} else {
self.calculate_accounts_hash(slot, ancestors, check_hash)
@ -5754,8 +5754,8 @@ impl AccountsDb {
&bounds,
config.check_hash,
config
.accounts_cache_and_ancestors
.map(|(a, b)| (a, b, &self.accounts_index)),
.ancestors
.map(|a| (&self.accounts_cache, a, &self.accounts_index)),
hash.filler_account_suffix.as_ref(),
)?;
@ -7929,7 +7929,7 @@ pub mod tests {
use_bg_thread_pool: false,
stats: HashStats::default(),
check_hash: false,
accounts_cache_and_ancestors: None,
ancestors: None,
})
.unwrap();
let expected_hash = Hash::from_str("GKot5hBsd81kMupNCXHaqbhv3huEbxAFMLnpcX2hniwn").unwrap();
@ -7953,7 +7953,7 @@ pub mod tests {
use_bg_thread_pool: false,
stats: HashStats::default(),
check_hash: false,
accounts_cache_and_ancestors: None,
ancestors: None,
})
.unwrap();

View File

@ -1,8 +1,5 @@
use {
crate::{
accounts_cache::AccountsCache, accounts_db::SnapshotStorages, ancestors::Ancestors,
sorted_storages::SortedStorages,
},
crate::{accounts_db::SnapshotStorages, ancestors::Ancestors, sorted_storages::SortedStorages},
log::*,
rayon::prelude::*,
solana_measure::measure::Measure,
@ -28,7 +25,7 @@ pub struct CalcAccountsHashConfig<'a> {
pub use_bg_thread_pool: bool,
pub stats: HashStats,
pub check_hash: bool,
pub accounts_cache_and_ancestors: Option<(&'a AccountsCache, &'a Ancestors)>,
pub ancestors: Option<&'a Ancestors>,
// to come soon
/*
pub rent_collector: RentCollector,