From dde4b5d1ef1971766fe9b96ac34695076af9d6aa Mon Sep 17 00:00:00 2001 From: Brooks Date: Wed, 25 Jan 2023 17:01:01 -0500 Subject: [PATCH] Adds AccountsDb::get_bank_hash_info() (#29908) --- runtime/src/accounts.rs | 4 ++-- runtime/src/accounts_db.rs | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/runtime/src/accounts.rs b/runtime/src/accounts.rs index 519900b76088e5..984898f2a4f701 100644 --- a/runtime/src/accounts.rs +++ b/runtime/src/accounts.rs @@ -2443,7 +2443,6 @@ mod tests { } #[test] - #[should_panic] fn test_accounts_empty_bank_hash() { let accounts = Accounts::new_with_config_for_tests( Vec::new(), @@ -2451,7 +2450,8 @@ mod tests { AccountSecondaryIndexes::default(), AccountShrinkThreshold::default(), ); - accounts.bank_hash_info_at(1); + assert!(accounts.accounts_db.get_bank_hash_info(0).is_some()); + assert!(accounts.accounts_db.get_bank_hash_info(1).is_none()); } #[test] diff --git a/runtime/src/accounts_db.rs b/runtime/src/accounts_db.rs index 11725744688e19..897314688b4848 100644 --- a/runtime/src/accounts_db.rs +++ b/runtime/src/accounts_db.rs @@ -7547,6 +7547,11 @@ impl AccountsDb { accounts_delta_hash } + /// Get the bank hash info for `slot` + pub fn get_bank_hash_info(&self, slot: Slot) -> Option { + self.bank_hashes.read().unwrap().get(&slot).cloned() + } + fn update_index<'a, T: ReadableAccount + Sync>( &self, infos: Vec,