diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index 81474243fe..fc91292829 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -676,15 +676,15 @@ pub struct AccountsIndex { pub removed_bank_ids: Mutex>, } -impl Default for AccountsIndex { +impl< + T: 'static + Clone + IsCached + ZeroLamport + std::marker::Sync + std::marker::Send + Debug, + > Default for AccountsIndex +{ fn default() -> Self { - let bins = BINS_DEFAULT; + let (account_maps, bin_calculator) = Self::allocate_accounts_index(BINS_DEFAULT); Self { - account_maps: (0..bins) - .into_iter() - .map(|_| RwLock::new(AccountMap::default())) - .collect::>(), - bin_calculator: PubkeyBinCalculator16::new(bins), + account_maps, + bin_calculator, program_id_index: SecondaryIndex::::new( "program_id_index_stats", ), @@ -705,6 +705,14 @@ impl< T: 'static + Clone + IsCached + ZeroLamport + std::marker::Sync + std::marker::Send + Debug, > AccountsIndex { + fn allocate_accounts_index(bins: usize) -> (LockMapType, PubkeyBinCalculator16) { + let account_maps = (0..bins) + .into_iter() + .map(|_| RwLock::new(AccountMap::default())) + .collect::>(); + let bin_calculator = PubkeyBinCalculator16::new(bins); + (account_maps, bin_calculator) + } fn iter(&self, range: Option) -> AccountsIndexIterator where R: RangeBounds,