From f500c99a6d11a55d9db06b50386451020f411b64 Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Sat, 18 Sep 2021 09:54:00 -0500 Subject: [PATCH] pass AcctIdxConfig to BucketMapHolder (#19997) --- runtime/src/accounts_index_storage.rs | 2 +- runtime/src/bucket_map_holder.rs | 10 +++++----- runtime/src/in_mem_accounts_index.rs | 7 +++++-- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/runtime/src/accounts_index_storage.rs b/runtime/src/accounts_index_storage.rs index e07210adb5..dd1817f84d 100644 --- a/runtime/src/accounts_index_storage.rs +++ b/runtime/src/accounts_index_storage.rs @@ -47,7 +47,7 @@ impl Drop for AccountsIndexStorage { impl AccountsIndexStorage { pub fn new(bins: usize, config: &Option) -> AccountsIndexStorage { - let storage = Arc::new(BucketMapHolder::new(bins)); + let storage = Arc::new(BucketMapHolder::new(bins, config)); let in_mem = (0..bins) .into_iter() diff --git a/runtime/src/bucket_map_holder.rs b/runtime/src/bucket_map_holder.rs index 2f5175e5bc..9c22461ca7 100644 --- a/runtime/src/bucket_map_holder.rs +++ b/runtime/src/bucket_map_holder.rs @@ -1,4 +1,4 @@ -use crate::accounts_index::IndexValue; +use crate::accounts_index::{AccountsIndexConfig, IndexValue}; use crate::bucket_map_holder_stats::BucketMapHolderStats; use crate::waitable_condvar::WaitableCondvar; use std::fmt::Debug; @@ -49,7 +49,7 @@ impl BucketMapHolder { self.count_ages_flushed.load(Ordering::Relaxed) >= self.bins } - pub fn new(bins: usize) -> Self { + pub fn new(bins: usize, _config: &Option) -> Self { Self { count_ages_flushed: AtomicUsize::default(), age: AtomicU8::default(), @@ -83,7 +83,7 @@ pub mod tests { fn test_next_bucket_to_flush() { solana_logger::setup(); let bins = 4; - let test = BucketMapHolder::::new(bins); + let test = BucketMapHolder::::new(bins, &Some(AccountsIndexConfig::default())); let visited = (0..bins) .into_iter() .map(|_| AtomicUsize::default()) @@ -107,7 +107,7 @@ pub mod tests { fn test_age_increment() { solana_logger::setup(); let bins = 4; - let test = BucketMapHolder::::new(bins); + let test = BucketMapHolder::::new(bins, &Some(AccountsIndexConfig::default())); for age in 0..513 { assert_eq!(test.current_age(), (age % 256) as Age); @@ -125,7 +125,7 @@ pub mod tests { fn test_age_broad() { solana_logger::setup(); let bins = 4; - let test = BucketMapHolder::::new(bins); + let test = BucketMapHolder::::new(bins, &Some(AccountsIndexConfig::default())); assert_eq!(test.current_age(), 0); assert!(!test.all_buckets_flushed_at_current_age()); // inc all but 1 diff --git a/runtime/src/in_mem_accounts_index.rs b/runtime/src/in_mem_accounts_index.rs index 655bb63217..57b016f1fb 100644 --- a/runtime/src/in_mem_accounts_index.rs +++ b/runtime/src/in_mem_accounts_index.rs @@ -378,10 +378,13 @@ impl InMemAccountsIndex { #[cfg(test)] mod tests { use super::*; - use crate::accounts_index::BINS_FOR_TESTING; + use crate::accounts_index::{AccountsIndexConfig, BINS_FOR_TESTING}; fn new_for_test() -> InMemAccountsIndex { - let holder = Arc::new(BucketMapHolder::new(BINS_FOR_TESTING)); + let holder = Arc::new(BucketMapHolder::new( + BINS_FOR_TESTING, + &Some(AccountsIndexConfig::default()), + )); InMemAccountsIndex::new(&holder, BINS_FOR_TESTING) }