accounts_db calls AccountsDb::new(bins) (#19068)
This commit is contained in:
parent
40914de811
commit
5cf28689e6
|
@ -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,
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue