Adds AccountsDb::get_bank_hash_info() (#29908)

This commit is contained in:
Brooks 2023-01-25 17:01:01 -05:00 committed by GitHub
parent fa39bfef6b
commit dde4b5d1ef
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 2 deletions

View File

@ -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]

View File

@ -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<BankHashInfo> {
self.bank_hashes.read().unwrap().get(&slot).cloned()
}
fn update_index<'a, T: ReadableAccount + Sync>(
&self,
infos: Vec<AccountInfo>,