Renames variant to CalcAccountsHashDataSource::IndexForTests (#28623)

This commit is contained in:
Brooks Prumo 2022-10-29 08:55:33 -04:00 committed by GitHub
parent c7cf598582
commit bfa62da29e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 16 additions and 9 deletions

View File

@ -298,7 +298,11 @@ impl SnapshotRequestHandler {
// We have to use the index version here. // We have to use the index version here.
// We cannot calculate the non-index way because cache has not been flushed and stores don't match reality. // We cannot calculate the non-index way because cache has not been flushed and stores don't match reality.
// This comment is out of date and can be re-evaluated. // This comment is out of date and can be re-evaluated.
snapshot_root_bank.update_accounts_hash(CalcAccountsHashDataSource::Index, false, false) snapshot_root_bank.update_accounts_hash(
CalcAccountsHashDataSource::IndexForTests,
false,
false,
)
} else { } else {
Hash::default() Hash::default()
}; };

View File

@ -6967,7 +6967,7 @@ impl AccountsDb {
is_startup: bool, is_startup: bool,
) -> (Hash, u64) { ) -> (Hash, u64) {
self.update_accounts_hash( self.update_accounts_hash(
CalcAccountsHashDataSource::Index, CalcAccountsHashDataSource::IndexForTests,
debug_verify, debug_verify,
slot, slot,
ancestors, ancestors,
@ -7305,7 +7305,7 @@ impl AccountsDb {
self.calculate_accounts_hash_from_storages(config, &storages, timings) self.calculate_accounts_hash_from_storages(config, &storages, timings)
} }
CalcAccountsHashDataSource::Index => { CalcAccountsHashDataSource::IndexForTests => {
self.calculate_accounts_hash_from_index(slot, config) self.calculate_accounts_hash_from_index(slot, config)
} }
} }
@ -7324,8 +7324,8 @@ impl AccountsDb {
if debug_verify { if debug_verify {
// calculate the other way (store or non-store) and verify results match. // calculate the other way (store or non-store) and verify results match.
let data_source_other = match data_source { let data_source_other = match data_source {
CalcAccountsHashDataSource::Index => CalcAccountsHashDataSource::Storages, CalcAccountsHashDataSource::IndexForTests => CalcAccountsHashDataSource::Storages,
CalcAccountsHashDataSource::Storages => CalcAccountsHashDataSource::Index, CalcAccountsHashDataSource::Storages => CalcAccountsHashDataSource::IndexForTests,
}; };
let (hash_other, total_lamports_other) = let (hash_other, total_lamports_other) =
self.calculate_accounts_hash(data_source_other, slot, &config)?; self.calculate_accounts_hash(data_source_other, slot, &config)?;
@ -9456,9 +9456,12 @@ impl AccountsDb {
} }
/// Specify the source of the accounts data when calculating the accounts hash /// Specify the source of the accounts data when calculating the accounts hash
///
/// Using the Index is meant for tests and debugging; not intended during normal validator
/// operation.
#[derive(Debug, Copy, Clone, Eq, PartialEq)] #[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub enum CalcAccountsHashDataSource { pub enum CalcAccountsHashDataSource {
Index, IndexForTests,
Storages, Storages,
} }
@ -12497,7 +12500,7 @@ pub mod tests {
db.add_root(some_slot); db.add_root(some_slot);
let check_hash = true; let check_hash = true;
for data_source in [ for data_source in [
CalcAccountsHashDataSource::Index, CalcAccountsHashDataSource::IndexForTests,
CalcAccountsHashDataSource::Storages, CalcAccountsHashDataSource::Storages,
] { ] {
assert!(db assert!(db
@ -12565,7 +12568,7 @@ pub mod tests {
) )
.unwrap(), .unwrap(),
db.calculate_accounts_hash( db.calculate_accounts_hash(
CalcAccountsHashDataSource::Index, CalcAccountsHashDataSource::IndexForTests,
some_slot, some_slot,
&CalcAccountsHashConfig { &CalcAccountsHashConfig {
use_bg_thread_pool: true, // is_startup used to be false use_bg_thread_pool: true, // is_startup used to be false

View File

@ -7034,7 +7034,7 @@ impl Bank {
} }
pub fn update_accounts_hash_for_tests(&self) -> Hash { pub fn update_accounts_hash_for_tests(&self) -> Hash {
self.update_accounts_hash(CalcAccountsHashDataSource::Index, false, false) self.update_accounts_hash(CalcAccountsHashDataSource::IndexForTests, false, false)
} }
/// A snapshot bank should be purged of 0 lamport accounts which are not part of the hash /// A snapshot bank should be purged of 0 lamport accounts which are not part of the hash