Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
Removes ReadAccountMapEntry
Browse files Browse the repository at this point in the history
  • Loading branch information
brooksprumo committed Feb 28, 2024
1 parent 8e7ce5d commit 21b7bf4
Showing 1 changed file with 1 addition and 38 deletions.
39 changes: 1 addition & 38 deletions accounts-db/src/accounts_index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ use {
secondary_index::*,
},
log::*,
ouroboros::self_referencing,
rand::{thread_rng, Rng},
rayon::{
iter::{IntoParallelIterator, ParallelIterator},
Expand All @@ -37,7 +36,7 @@ use {
path::PathBuf,
sync::{
atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering},
Arc, Mutex, OnceLock, RwLock, RwLockReadGuard, RwLockWriteGuard,
Arc, Mutex, OnceLock, RwLock, RwLockWriteGuard,
},
},
thiserror::Error,
Expand Down Expand Up @@ -339,42 +338,6 @@ impl<T: IndexValue> AccountMapEntryInner<T> {
}
}

#[self_referencing]
pub struct ReadAccountMapEntry<T: IndexValue> {
owned_entry: AccountMapEntry<T>,
#[borrows(owned_entry)]
#[covariant]
slot_list_guard: RwLockReadGuard<'this, SlotList<T>>,
}

impl<T: IndexValue> Debug for ReadAccountMapEntry<T> {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{:?}", self.borrow_owned_entry())
}
}

impl<T: IndexValue> ReadAccountMapEntry<T> {
pub fn from_account_map_entry(account_map_entry: AccountMapEntry<T>) -> Self {
ReadAccountMapEntryBuilder {
owned_entry: account_map_entry,
slot_list_guard_builder: |lock| lock.slot_list.read().unwrap(),
}
.build()
}

pub fn slot_list(&self) -> &SlotList<T> {
self.borrow_slot_list_guard()
}

pub fn ref_count(&self) -> RefCount {
self.borrow_owned_entry().ref_count()
}

pub fn addref(&self) {
self.borrow_owned_entry().addref();
}
}

/// can be used to pre-allocate structures for insertion into accounts index outside of lock
pub enum PreAllocatedAccountMapEntry<T: IndexValue> {
Entry(AccountMapEntry<T>),
Expand Down

0 comments on commit 21b7bf4

Please sign in to comment.