extract expected cluster type (#15615)

* extract expected cluster type

* fix clippy warning

* more clippy
This commit is contained in:
Jeff Washington (jwash) 2021-03-02 13:55:34 -06:00 committed by GitHub
parent 7435a7b0ed
commit a2c47db920
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 10 deletions

View File

@ -1161,6 +1161,11 @@ impl AccountsDb {
) )
} }
pub fn expected_cluster_type(&self) -> ClusterType {
self.cluster_type
.expect("Cluster type must be set at initialization")
}
// Reclaim older states of rooted accounts for AccountsDb bloat mitigation // Reclaim older states of rooted accounts for AccountsDb bloat mitigation
fn clean_old_rooted_accounts( fn clean_old_rooted_accounts(
&self, &self,
@ -3529,9 +3534,7 @@ impl AccountsDb {
let computed_hash = loaded_account let computed_hash = loaded_account
.compute_hash( .compute_hash(
*slot, *slot,
&self.cluster_type.expect( &self.expected_cluster_type(),
"Cluster type must be set at initialization",
),
pubkey, pubkey,
); );
if computed_hash != *loaded_hash { if computed_hash != *loaded_hash {
@ -4172,13 +4175,7 @@ impl AccountsDb {
} }
self.assert_frozen_accounts(accounts); self.assert_frozen_accounts(accounts);
let mut hash_time = Measure::start("hash_accounts"); let mut hash_time = Measure::start("hash_accounts");
let hashes = self.hash_accounts( let hashes = self.hash_accounts(slot, accounts, &self.expected_cluster_type());
slot,
accounts,
&self
.cluster_type
.expect("Cluster type must be set at initialization"),
);
hash_time.stop(); hash_time.stop();
self.stats self.stats
.store_hash_accounts .store_hash_accounts