Skip to content

Commit

Permalink
Adds AccountsDb::get_bank_hash_info() (solana-labs#29908)
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo authored Jan 25, 2023
1 parent fa39bfe commit dde4b5d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions runtime/src/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2443,15 +2443,15 @@ mod tests {
}

#[test]
#[should_panic]
fn test_accounts_empty_bank_hash() {
let accounts = Accounts::new_with_config_for_tests(
Vec::new(),
&ClusterType::Development,
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]
Expand Down
5 changes: 5 additions & 0 deletions runtime/src/accounts_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>,
Expand Down

0 comments on commit dde4b5d

Please sign in to comment.