introduce LockMapType for accounts_index (#18021)
This commit is contained in:
committed by
GitHub
parent
bab96e878e
commit
0a81c37fce
@ -524,7 +524,7 @@ pub struct AccountsIndexRootsStats {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub struct AccountsIndexIterator<'a, T> {
|
pub struct AccountsIndexIterator<'a, T> {
|
||||||
account_maps: &'a RwLock<AccountMap<Pubkey, AccountMapEntry<T>>>,
|
account_maps: &'a LockMapType<T>,
|
||||||
start_bound: Bound<Pubkey>,
|
start_bound: Bound<Pubkey>,
|
||||||
end_bound: Bound<Pubkey>,
|
end_bound: Bound<Pubkey>,
|
||||||
is_finished: bool,
|
is_finished: bool,
|
||||||
@ -539,10 +539,7 @@ impl<'a, T> AccountsIndexIterator<'a, T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new<R>(
|
pub fn new<R>(account_maps: &'a LockMapType<T>, range: Option<R>) -> Self
|
||||||
account_maps: &'a RwLock<AccountMap<Pubkey, AccountMapEntry<T>>>,
|
|
||||||
range: Option<R>,
|
|
||||||
) -> Self
|
|
||||||
where
|
where
|
||||||
R: RangeBounds<Pubkey>,
|
R: RangeBounds<Pubkey>,
|
||||||
{
|
{
|
||||||
@ -592,8 +589,9 @@ pub trait ZeroLamport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type MapType<T> = AccountMap<Pubkey, AccountMapEntry<T>>;
|
type MapType<T> = AccountMap<Pubkey, AccountMapEntry<T>>;
|
||||||
type AccountMapsWriteLock<'a, T> = RwLockWriteGuard<'a, AccountMap<Pubkey, AccountMapEntry<T>>>;
|
type LockMapType<T> = RwLock<MapType<T>>;
|
||||||
type AccountMapsReadLock<'a, T> = RwLockReadGuard<'a, AccountMap<Pubkey, AccountMapEntry<T>>>;
|
type AccountMapsWriteLock<'a, T> = RwLockWriteGuard<'a, MapType<T>>;
|
||||||
|
type AccountMapsReadLock<'a, T> = RwLockReadGuard<'a, MapType<T>>;
|
||||||
|
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
pub struct ScanSlotTracker {
|
pub struct ScanSlotTracker {
|
||||||
@ -613,7 +611,7 @@ impl ScanSlotTracker {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct AccountsIndex<T> {
|
pub struct AccountsIndex<T> {
|
||||||
pub account_maps: RwLock<MapType<T>>,
|
pub account_maps: LockMapType<T>,
|
||||||
program_id_index: SecondaryIndex<DashMapSecondaryIndexEntry>,
|
program_id_index: SecondaryIndex<DashMapSecondaryIndexEntry>,
|
||||||
spl_token_mint_index: SecondaryIndex<DashMapSecondaryIndexEntry>,
|
spl_token_mint_index: SecondaryIndex<DashMapSecondaryIndexEntry>,
|
||||||
spl_token_owner_index: SecondaryIndex<RwLockSecondaryIndexEntry>,
|
spl_token_owner_index: SecondaryIndex<RwLockSecondaryIndexEntry>,
|
||||||
@ -636,7 +634,7 @@ pub struct AccountsIndex<T> {
|
|||||||
impl<T> Default for AccountsIndex<T> {
|
impl<T> Default for AccountsIndex<T> {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
account_maps: RwLock::<AccountMap<Pubkey, AccountMapEntry<T>>>::default(),
|
account_maps: LockMapType::<T>::default(),
|
||||||
program_id_index: SecondaryIndex::<DashMapSecondaryIndexEntry>::new(
|
program_id_index: SecondaryIndex::<DashMapSecondaryIndexEntry>::new(
|
||||||
"program_id_index_stats",
|
"program_id_index_stats",
|
||||||
),
|
),
|
||||||
|
Reference in New Issue
Block a user