From c65c580b20acfdbacc8efdd3cc3273ebd2767ed4 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 18 Jun 2021 01:39:27 +0000 Subject: [PATCH] introduce LockMapType for accounts_index (#18021) (#18051) (cherry picked from commit 0a81c37fce73749e6096ba7e2dadacff606e221d) Co-authored-by: Jeff Washington (jwash) <75863576+jeffwashington@users.noreply.github.com> --- 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 37a2f670e8..df2a6e517e 100644 --- a/runtime/src/accounts_index.rs +++ b/runtime/src/accounts_index.rs @@ -513,7 +513,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, @@ -528,10 +528,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, { @@ -581,12 +578,13 @@ 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)] 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, @@ -598,7 +596,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", ),