diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index 3b1f644275..2cc0aeb374 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -30,17 +30,19 @@ use thiserror::Error; pub const ITER_BATCH_SIZE: usize = 1000; pub const BINS_DEFAULT: usize = 8192; +pub const BINS_FOR_TESTING: usize = BINS_DEFAULT; +pub const BINS_FOR_BENCHMARKS: usize = BINS_DEFAULT; pub const ACCOUNTS_INDEX_CONFIG_FOR_TESTING: AccountsIndexConfig = AccountsIndexConfig { - bins: Some(BINS_DEFAULT), + bins: Some(BINS_FOR_TESTING), }; pub const ACCOUNTS_INDEX_CONFIG_FOR_BENCHMARKS: AccountsIndexConfig = AccountsIndexConfig { - bins: Some(BINS_DEFAULT), + bins: Some(BINS_FOR_BENCHMARKS), }; pub type ScanResult = Result; pub type SlotList = Vec<(Slot, T)>; pub type SlotSlice<'s, T> = &'s [(Slot, T)]; pub type RefCount = u64; -pub type AccountMap = HashMap; +pub type AccountMap = HashMap; type AccountMapEntry = Arc>; @@ -117,21 +119,21 @@ impl AccountMapEntryInner { } } -pub enum AccountIndexGetResult<'a, T: 'static> { +pub enum AccountIndexGetResult<'a, T: IsCached> { Found(ReadAccountMapEntry, usize), NotFoundOnFork, Missing(AccountMapsReadLock<'a, T>), } #[self_referencing] -pub struct ReadAccountMapEntry { +pub struct ReadAccountMapEntry { owned_entry: AccountMapEntry, #[borrows(owned_entry)] #[covariant] slot_list_guard: RwLockReadGuard<'this, SlotList>, } -impl ReadAccountMapEntry { +impl ReadAccountMapEntry { pub fn from_account_map_entry(account_map_entry: AccountMapEntry) -> Self { ReadAccountMapEntryBuilder { owned_entry: account_map_entry, @@ -162,7 +164,7 @@ impl ReadAccountMapEntry { } #[self_referencing] -pub struct WriteAccountMapEntry { +pub struct WriteAccountMapEntry { owned_entry: AccountMapEntry, #[borrows(owned_entry)] #[covariant] @@ -709,7 +711,7 @@ impl<'a, T> AccountsIndexIterator<'a, T> { } } -impl<'a, T: 'static + Clone> Iterator for AccountsIndexIterator<'a, T> { +impl<'a, T: IsCached> Iterator for AccountsIndexIterator<'a, T> { type Item = Vec<(Pubkey, AccountMapEntry)>; fn next(&mut self) -> Option { if self.is_finished { @@ -747,7 +749,7 @@ pub trait ZeroLamport { fn is_zero_lamport(&self) -> bool; } -type MapType = AccountMap>; +type MapType = AccountMap>; type LockMapType = Vec>>; type LockMapTypeSlice = [RwLock>]; type AccountMapsWriteLock<'a, T> = RwLockWriteGuard<'a, MapType>; @@ -1953,7 +1955,7 @@ pub mod tests { } } - impl<'a, T: 'static> AccountIndexGetResult<'a, T> { + impl<'a, T: IsCached> AccountIndexGetResult<'a, T> { pub fn unwrap(self) -> (ReadAccountMapEntry, usize) { match self { AccountIndexGetResult::Found(lock, size) => (lock, size),