solana_accounts_db::accounts_index

Struct AccountsIndex

Source
pub struct AccountsIndex<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> {
    pub account_maps: Vec<AccountMap<T, U>>,
    pub bin_calculator: PubkeyBinCalculator24,
    pub roots_tracker: RwLock<RootsTracker>,
    pub removed_bank_ids: Mutex<HashSet<BankId>>,
    pub scan_results_limit_bytes: Option<usize>,
    pub purge_older_root_entries_one_slot_list: AtomicUsize,
    pub roots_added: AtomicUsize,
    pub roots_removed: AtomicUsize,
    pub active_scans: AtomicUsize,
    pub max_distance_to_min_scan_slot: AtomicU64,
    pub unref_zero_count: AtomicU64,
    pub rent_paying_accounts_by_partition: OnceLock<RentPayingAccountsByPartition>,
    /* private fields */
}
Expand description

T: account info type to interact in in-memory items U: account info type to be persisted to disk

Fields§

§account_maps: Vec<AccountMap<T, U>>§bin_calculator: PubkeyBinCalculator24§roots_tracker: RwLock<RootsTracker>§removed_bank_ids: Mutex<HashSet<BankId>>§scan_results_limit_bytes: Option<usize>

when a scan’s accumulated data exceeds this limit, abort the scan

§purge_older_root_entries_one_slot_list: AtomicUsize§roots_added: AtomicUsize

§roots added since last check

§roots_removed: AtomicUsize

§roots removed since last check

§active_scans: AtomicUsize

§scans active currently

§max_distance_to_min_scan_slot: AtomicU64

§of slots between latest max and latest scan

§unref_zero_count: AtomicU64§rent_paying_accounts_by_partition: OnceLock<RentPayingAccountsByPartition>

populated at generate_index time - accounts that could possibly be rent paying

Implementations§

Source§

impl<T: IndexValue, U: DiskIndexValue + From<T> + Into<T>> AccountsIndex<T, U>

Source

pub fn default_for_tests() -> Self

Source

pub fn new(config: Option<AccountsIndexConfig>, exit: Arc<AtomicBool>) -> Self

Source

pub fn is_disk_index_enabled(&self) -> bool

is the accounts index using disk as a backing store

Source

pub fn get_and_then<R>( &self, pubkey: &Pubkey, callback: impl FnOnce(Option<&AccountMapEntryInner<T>>) -> (bool, R), ) -> R

Gets the index’s entry for pubkey and applies callback to it

If callback’s boolean return value is true, add this entry to the in-mem cache.

Source

pub fn get_cloned( &self, pubkey: &Pubkey, ) -> Option<Arc<AccountMapEntryInner<T>>>

Gets the index’s entry for pubkey and clones it

Prefer get_and_then() whenever possible.

Source

pub fn contains(&self, pubkey: &Pubkey) -> bool

Is pubkey in the index?

Source

pub fn handle_dead_keys( &self, dead_keys: &[&Pubkey], account_indexes: &AccountSecondaryIndexes, ) -> HashSet<Pubkey>

Remove keys from the account index if the key’s slot list is empty. Returns the keys that were removed from the index. These keys should not be accessed again in the current code path.

Source

pub fn get_rooted_entries( &self, slice: SlotSlice<'_, T>, max_inclusive: Option<Slot>, ) -> SlotList<T>

Source

pub fn min_ongoing_scan_root(&self) -> Option<Slot>

Source

pub fn hold_range_in_memory<R>( &self, range: &R, start_holding: bool, thread_pool: &ThreadPool, )
where R: RangeBounds<Pubkey> + Debug + Sync,

Source

pub fn set_startup(&self, value: Startup)

Source

pub fn get_startup_remaining_items_to_flush_estimate(&self) -> usize

Source

pub fn get_index_key_size( &self, index: &AccountIndex, index_key: &Pubkey, ) -> Option<usize>

Source

pub fn bins(&self) -> usize

Source

pub fn upsert( &self, new_slot: Slot, old_slot: Slot, pubkey: &Pubkey, account: &impl ReadableAccount, account_indexes: &AccountSecondaryIndexes, account_info: T, reclaims: &mut SlotList<T>, reclaim: UpsertReclaim, )

Updates the given pubkey at the given slot with the new account information. on return, the index’s previous account info may be returned in ‘reclaims’ depending on ‘previous_slot_entry_was_cached’

Source

pub fn ref_count_from_storage(&self, pubkey: &Pubkey) -> RefCount

Source

pub fn clean_rooted_entries( &self, pubkey: &Pubkey, reclaims: &mut SlotList<T>, max_clean_root_inclusive: Option<Slot>, ) -> bool

return true if pubkey was removed from the accounts index or does not exist in the accounts index This means it should NOT be unref’d later.

Source

pub fn get_rooted_from_list<'a>( &self, slots: impl Iterator<Item = &'a Slot>, ) -> Vec<Slot>

Given a list of slots, return a new list of only the slots that are rooted

Source

pub fn is_alive_root(&self, slot: Slot) -> bool

Source

pub fn add_root(&self, slot: Slot)

Source

pub fn add_uncleaned_roots<I>(&self, roots: I)
where I: IntoIterator<Item = Slot>,

Source

pub fn max_root_inclusive(&self) -> Slot

Source

pub fn clean_dead_slot(&self, slot: Slot) -> bool

Remove the slot when the storage for the slot is freed Accounts no longer reference this slot. return true if slot was a root

Source

pub fn min_alive_root(&self) -> Option<Slot>

Source

pub fn num_alive_roots(&self) -> usize

Source

pub fn all_alive_roots(&self) -> Vec<Slot>

Source

pub fn clone_uncleaned_roots(&self) -> IntSet<Slot>

Source

pub fn uncleaned_roots_len(&self) -> usize

Trait Implementations§

Source§

impl<T: Debug + IndexValue, U: Debug + DiskIndexValue + From<T> + Into<T>> Debug for AccountsIndex<T, U>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, U> !Freeze for AccountsIndex<T, U>

§

impl<T, U> !RefUnwindSafe for AccountsIndex<T, U>

§

impl<T, U> Send for AccountsIndex<T, U>

§

impl<T, U> Sync for AccountsIndex<T, U>

§

impl<T, U> Unpin for AccountsIndex<T, U>

§

impl<T, U> !UnwindSafe for AccountsIndex<T, U>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize = _

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T