accounts_db calls AccountsDb::new(bins) (#19068)

This commit is contained in:
Jeff Washington (jwash) 2021-08-05 11:15:26 -05:00 committed by GitHub
parent 40914de811
commit 5cf28689e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 3 deletions

View File

@ -1352,7 +1352,7 @@ impl Default for AccountsDb {
let mut bank_hashes = HashMap::new();
bank_hashes.insert(0, BankHashInfo::default());
AccountsDb {
accounts_index: AccountsIndex::default(),
accounts_index: AccountsIndex::new(crate::accounts_index::BINS_DEFAULT),
storage: AccountStorage::default(),
accounts_cache: AccountsCache::default(),
sender_bg_hasher: None,

View File

@ -32,7 +32,7 @@ use std::{
use thiserror::Error;
pub const ITER_BATCH_SIZE: usize = 1000;
const BINS_DEFAULT: usize = 16;
pub const BINS_DEFAULT: usize = 16;
const BINS_FOR_TESTING: usize = BINS_DEFAULT;
pub type ScanResult<T> = Result<T, ScanError>;
pub type SlotList<T> = Vec<(Slot, T)>;
@ -759,7 +759,7 @@ impl<
Self::new(BINS_FOR_TESTING)
}
fn new(bins: usize) -> Self {
pub fn new(bins: usize) -> Self {
let (account_maps, bin_calculator) = Self::allocate_accounts_index(bins);
Self {
account_maps,
@ -3987,4 +3987,10 @@ pub mod tests {
assert_eq!(iter.start_bin(), bins - 1); // start at highest possible pubkey, so bins - 1
assert_eq!(iter.end_bin_inclusive(), bins - 1);
}
#[test]
#[should_panic(expected = "bins.is_power_of_two()")]
fn test_illegal_bins() {
AccountsIndex::<bool>::new(3);
}
}