use CalcAccountsHashConfig in calculate_accounts_hash (#23987)

This commit is contained in:
Jeff Washington (jwash) 2022-03-29 22:05:47 -05:00 committed by GitHub
parent 794645d092
commit 5a613e9b6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 6 deletions

View File

@ -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<Vec<Hash>> = if check_hash {
let hashes: Vec<Vec<Hash>> = 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),
},
)
}
}

View File

@ -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<R>(&'a self, range: R) -> SortedStoragesIter<'a>
where