AccountsIndexStorage holds InMemAccountsIndex[] (#19947)
This commit is contained in:
parent
49d3d79459
commit
66e0fafc21
|
@ -745,7 +745,7 @@ impl<T: IndexValue> AccountsIndex<T> {
|
|||
let storage = AccountsIndexStorage::new(bins);
|
||||
let account_maps = (0..bins)
|
||||
.into_iter()
|
||||
.map(|bin| RwLock::new(Arc::new(InMemAccountsIndex::new(&storage, bin))))
|
||||
.map(|bin| RwLock::new(Arc::clone(&storage.in_mem[bin])))
|
||||
.collect::<Vec<_>>();
|
||||
(account_maps, bin_calculator, storage)
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
use crate::accounts_index::IndexValue;
|
||||
use crate::bucket_map_holder::BucketMapHolder;
|
||||
use crate::in_mem_accounts_index::InMemAccountsIndex;
|
||||
use crate::waitable_condvar::WaitableCondvar;
|
||||
use std::fmt::Debug;
|
||||
use std::{
|
||||
|
@ -22,6 +23,7 @@ pub struct AccountsIndexStorage<T: IndexValue> {
|
|||
|
||||
// eventually the backing storage
|
||||
storage: Arc<BucketMapHolder<T>>,
|
||||
pub in_mem: Vec<Arc<InMemAccountsIndex<T>>>,
|
||||
}
|
||||
|
||||
impl<T: IndexValue> Debug for AccountsIndexStorage<T> {
|
||||
|
@ -43,6 +45,12 @@ impl<T: IndexValue> Drop for AccountsIndexStorage<T> {
|
|||
impl<T: IndexValue> AccountsIndexStorage<T> {
|
||||
pub fn new(bins: usize) -> AccountsIndexStorage<T> {
|
||||
let storage = Arc::new(BucketMapHolder::new(bins));
|
||||
|
||||
let in_mem = (0..bins)
|
||||
.into_iter()
|
||||
.map(|bin| Arc::new(InMemAccountsIndex::new(&storage, bin)))
|
||||
.collect();
|
||||
|
||||
let storage_ = storage.clone();
|
||||
let exit = Arc::new(AtomicBool::default());
|
||||
let exit_ = exit.clone();
|
||||
|
@ -62,6 +70,7 @@ impl<T: IndexValue> AccountsIndexStorage<T> {
|
|||
wait,
|
||||
handle,
|
||||
storage,
|
||||
in_mem,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,6 @@ impl<T: IndexValue> BucketMapHolder<T> {
|
|||
_phantom: std::marker::PhantomData::<T>::default(),
|
||||
}
|
||||
}
|
||||
|
||||
// intended to execute in a bg thread
|
||||
pub fn background(&self, exit: Arc<AtomicBool>, wait: Arc<WaitableCondvar>) {
|
||||
loop {
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
use crate::accounts_index::{
|
||||
AccountMapEntry, AccountMapEntryInner, IndexValue, SlotList, WriteAccountMapEntry,
|
||||
};
|
||||
use crate::accounts_index_storage::AccountsIndexStorage;
|
||||
use crate::bucket_map_holder::BucketMapHolder;
|
||||
use crate::bucket_map_holder_stats::BucketMapHolderStats;
|
||||
use solana_measure::measure::Measure;
|
||||
|
@ -29,10 +28,10 @@ impl<T: IndexValue> Debug for InMemAccountsIndex<T> {
|
|||
}
|
||||
|
||||
impl<T: IndexValue> InMemAccountsIndex<T> {
|
||||
pub fn new(storage: &AccountsIndexStorage<T>, bin: usize) -> Self {
|
||||
pub fn new(storage: &Arc<BucketMapHolder<T>>, bin: usize) -> Self {
|
||||
Self {
|
||||
map_internal: RwLock::default(),
|
||||
storage: storage.storage().clone(),
|
||||
storage: Arc::clone(storage),
|
||||
bin,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue