From 0a81c37fce73749e6096ba7e2dadacff606e221d Mon Sep 17 00:00:00 2001 From: "Jeff Washington (jwash)" <75863576+jeffwashington@users.noreply.github.com> Date: Thu, 17 Jun 2021 14:41:52 -0500 Subject: [PATCH] introduce LockMapType for accounts_index (#18021) --- runtime/src/accounts_index.rs | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/runtime/src/accounts_index.rs b/runtime/src/accounts_index.rs index b6e402e2ae..0acb02aa9f 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -524,7 +524,7 @@ pub struct AccountsIndexRootsStats { } pub struct AccountsIndexIterator<'a, T> { - account_maps: &'a RwLock>>, + account_maps: &'a LockMapType, start_bound: Bound, end_bound: Bound, is_finished: bool, @@ -539,10 +539,7 @@ impl<'a, T> AccountsIndexIterator<'a, T> { } } - pub fn new( - account_maps: &'a RwLock>>, - range: Option, - ) -> Self + pub fn new(account_maps: &'a LockMapType, range: Option) -> Self where R: RangeBounds, { @@ -592,8 +589,9 @@ pub trait ZeroLamport { } type MapType = AccountMap>; -type AccountMapsWriteLock<'a, T> = RwLockWriteGuard<'a, AccountMap>>; -type AccountMapsReadLock<'a, T> = RwLockReadGuard<'a, AccountMap>>; +type LockMapType = RwLock>; +type AccountMapsWriteLock<'a, T> = RwLockWriteGuard<'a, MapType>; +type AccountMapsReadLock<'a, T> = RwLockReadGuard<'a, MapType>; #[derive(Debug, Default)] pub struct ScanSlotTracker { @@ -613,7 +611,7 @@ impl ScanSlotTracker { #[derive(Debug)] pub struct AccountsIndex { - pub account_maps: RwLock>, + pub account_maps: LockMapType, program_id_index: SecondaryIndex, spl_token_mint_index: SecondaryIndex, spl_token_owner_index: SecondaryIndex, @@ -636,7 +634,7 @@ pub struct AccountsIndex { impl Default for AccountsIndex { fn default() -> Self { Self { - account_maps: RwLock::>>::default(), + account_maps: LockMapType::::default(), program_id_index: SecondaryIndex::::new( "program_id_index_stats", ),