pub struct AccountsDb {
Show 22 fields pub accounts_index: AccountsIndex<AccountInfo>, pub accounts_hash_complete_one_epoch_old: RwLock<Slot>, pub skip_rewrites: bool, pub ancient_append_vecs: bool, pub skip_initial_hash_calc: bool, pub storage: AccountStorage, pub accounts_cache: AccountsCache, pub next_id: AtomicAppendVecId, pub shrink_candidate_slots: Mutex<HashMap<Slot, HashMap<AppendVecId, Arc<AccountStorageEntry>>>>, pub shrink_candidate_slots_v1: Mutex<Vec<Slot>>, pub shrink_paths: RwLock<Option<Vec<PathBuf>>>, pub thread_pool: ThreadPool, pub thread_pool_clean: ThreadPool, pub bank_hashes: RwLock<HashMap<Slot, BankHashInfo>>, pub stats: AccountsStats, pub cluster_type: Option<ClusterType>, pub account_indexes: AccountSecondaryIndexes, pub caching_enabled: bool, pub filler_account_suffix: Option<Pubkey>, pub filler_accounts_per_slot: AtomicU64, pub filler_account_slots_remaining: AtomicU64, pub num_hash_scan_passes: Option<usize>, /* private fields */
}

Fields§

§accounts_index: AccountsIndex<AccountInfo>

Keeps tracks of index into AppendVec on a per slot basis

§accounts_hash_complete_one_epoch_old: RwLock<Slot>

slot that is one epoch older than the highest slot where accounts hash calculation has completed

§skip_rewrites: bool

true iff rent exempt accounts are not rewritten in their normal rent collection slot

§ancient_append_vecs: bool

true iff we want to squash old append vecs together into ‘ancient append vecs’

§skip_initial_hash_calc: bool

true iff we want to skip the initial hash calculation on startup

§storage: AccountStorage§accounts_cache: AccountsCache§next_id: AtomicAppendVecId

distribute the accounts across storage lists

§shrink_candidate_slots: Mutex<HashMap<Slot, HashMap<AppendVecId, Arc<AccountStorageEntry>>>>

Set of shrinkable stores organized by map of slot to append_vec_id

§shrink_candidate_slots_v1: Mutex<Vec<Slot>>

Legacy shrink slots to support non-cached code-path.

§shrink_paths: RwLock<Option<Vec<PathBuf>>>§thread_pool: ThreadPool

Thread pool used for par_iter

§thread_pool_clean: ThreadPool§bank_hashes: RwLock<HashMap<Slot, BankHashInfo>>§stats: AccountsStats§cluster_type: Option<ClusterType>§account_indexes: AccountSecondaryIndexes§caching_enabled: bool§filler_account_suffix: Option<Pubkey>§filler_accounts_per_slot: AtomicU64

number of filler accounts to add for each slot

§filler_account_slots_remaining: AtomicU64

number of slots remaining where filler accounts should be added

§num_hash_scan_passes: Option<usize>

Implementations§

source§

impl AccountsDb

source

pub fn notify_account_restore_from_snapshot(&self)

Notify the plugins of of account data when AccountsDb is restored from a snapshot. The data is streamed in the reverse order of the slots so that an account is only streamed once. At a slot, if the accounts is updated multiple times only the last write (with highest write_version) is notified.

source

pub fn notify_account_at_accounts_update( &self, slot: Slot, meta: &StoredMeta, account: &AccountSharedData, txn_signature: &Option<&Signature> )

source§

impl AccountsDb

source

pub fn default_for_tests() -> Self

source

pub fn new_for_tests(paths: Vec<PathBuf>, cluster_type: &ClusterType) -> Self

source

pub fn new_for_tests_with_caching( paths: Vec<PathBuf>, cluster_type: &ClusterType ) -> Self

source

pub fn new_with_config( paths: Vec<PathBuf>, cluster_type: &ClusterType, account_indexes: AccountSecondaryIndexes, caching_enabled: bool, shrink_ratio: AccountShrinkThreshold, accounts_db_config: Option<AccountsDbConfig>, accounts_update_notifier: Option<AccountsUpdateNotifier> ) -> Self

source

pub fn set_shrink_paths(&self, paths: Vec<PathBuf>)

source

pub fn file_size(&self) -> u64

source

pub fn new_single_for_tests() -> Self

source

pub fn new_single_for_tests_with_caching() -> Self

source

pub fn expected_cluster_type(&self) -> ClusterType

source

pub fn notify_accounts_hash_calculated_complete( &self, completed_slot: Slot, epoch_schedule: &EpochSchedule )

hash calc is completed as of ‘slot’ so, any process that wants to take action on really old slots can now proceed up to ‘completed_slot’-slots per epoch

source

pub fn clean_accounts( &self, max_clean_root: Option<Slot>, is_startup: bool, last_full_snapshot_slot: Option<Slot> )

source

pub fn should_move_to_ancient_append_vec( &self, all_storages: &SnapshotStorage, current_ancient: &mut Option<(Slot, Arc<AccountStorageEntry>)>, slot: Slot ) -> bool

return true if the accounts in this slot should be moved to an ancient append vec otherwise, return false and the caller can skip this slot side effect could be updating ‘current_ancient’

source

pub fn shrink_candidate_slots(&self) -> usize

source

pub fn shrink_all_slots( &self, is_startup: bool, last_full_snapshot_slot: Option<Slot> )

source

pub fn scan_accounts<F, A>( &self, ancestors: &Ancestors, bank_id: BankId, scan_func: F, config: &ScanConfig ) -> ScanResult<A>where F: Fn(&mut A, Option<(&Pubkey, AccountSharedData, Slot)>), A: Default,

source

pub fn unchecked_scan_accounts<F, A>( &self, metric_name: &'static str, ancestors: &Ancestors, scan_func: F, config: &ScanConfig ) -> Awhere F: Fn(&mut A, (&Pubkey, LoadedAccount<'_>, Slot)), A: Default,

source

pub fn range_scan_accounts<F, A, R>( &self, metric_name: &'static str, ancestors: &Ancestors, range: R, config: &ScanConfig, scan_func: F ) -> Awhere F: Fn(&mut A, Option<(&Pubkey, AccountSharedData, Slot)>), A: Default, R: RangeBounds<Pubkey> + Debug,

Only guaranteed to be safe when called from rent collection

source

pub fn index_scan_accounts<F, A>( &self, ancestors: &Ancestors, bank_id: BankId, index_key: IndexKey, scan_func: F, config: &ScanConfig ) -> ScanResult<(A, bool)>where F: Fn(&mut A, Option<(&Pubkey, AccountSharedData, Slot)>), A: Default,

source

pub fn scan_account_storage<R, B>( &self, slot: Slot, cache_map_func: impl Fn(LoadedAccount<'_>) -> Option<R> + Sync, storage_scan_func: impl Fn(&B, LoadedAccount<'_>) + Sync ) -> ScanStorageResult<R, B>where R: Send, B: Send + Default + Sync,

Scan a specific slot through all the account storage in parallel

source

pub fn set_hash(&self, slot: Slot, parent_slot: Slot)

source

pub fn load( &self, ancestors: &Ancestors, pubkey: &Pubkey, load_hint: LoadHint ) -> Option<(AccountSharedData, Slot)>

source

pub fn load_account_into_read_cache(&self, ancestors: &Ancestors, pubkey: &Pubkey)

source

pub fn load_with_fixed_root( &self, ancestors: &Ancestors, pubkey: &Pubkey, load_zero_lamports: LoadZeroLamports ) -> Option<(AccountSharedData, Slot)>

source

pub fn load_without_fixed_root( &self, ancestors: &Ancestors, pubkey: &Pubkey ) -> Option<(AccountSharedData, Slot)>

source

pub fn load_account_hash( &self, ancestors: &Ancestors, pubkey: &Pubkey, max_root: Option<Slot>, load_hint: LoadHint ) -> Option<Hash>

source

pub fn create_drop_bank_callback( &self, pruned_banks_sender: DroppedSlotsSender ) -> SendDroppedBankCallback

source

pub fn purge_slot(&self, slot: Slot, bank_id: BankId, is_serialized_with_abs: bool)

This should only be called after the Bank::drop() runs in bank.rs, See BANK_DROP_SAFETY comment below for more explanation.

  • is_serialized_with_abs - indicates whehter this call runs sequentially with all other accounts_db relevant calls, such as shrinking, purging etc., in account background service.
source

pub fn remove_unrooted_slots(&self, remove_slots: &[(Slot, BankId)])

source

pub fn hash_account_with_rent_epoch<T: ReadableAccount>( slot: Slot, account: &T, pubkey: &Pubkey, rent_epoch: Epoch ) -> Hash

source

pub fn hash_account<T: ReadableAccount>( slot: Slot, account: &T, pubkey: &Pubkey ) -> Hash

source

pub fn mark_slot_frozen(&self, slot: Slot)

source

pub fn expire_old_recycle_stores(&self)

source

pub fn flush_accounts_cache_slot(&self, slot: Slot)

source

pub fn flush_accounts_cache( &self, force_flush: bool, requested_flush_root: Option<Slot> )

source

pub fn find_unskipped_slot( &self, slot: Slot, ancestors: Option<&Ancestors> ) -> Option<Slot>

find slot >= ‘slot’ which is a root or in ‘ancestors’

source

pub fn checked_iterative_sum_for_capitalization( total_cap: u64, new_cap: u64 ) -> u64

source

pub fn checked_sum_for_capitalization<T: Iterator<Item = u64>>( balances: T ) -> u64

source

pub fn get_accounts_hash(&self, slot: Slot) -> Hash

source

pub fn update_accounts_hash( &self, slot: Slot, ancestors: &Ancestors, epoch_schedule: &EpochSchedule, rent_collector: &RentCollector ) -> (Hash, u64)

source

pub fn update_accounts_hash_with_index_option( &self, use_index: bool, debug_verify: bool, slot: Slot, ancestors: &Ancestors, expected_capitalization: Option<u64>, can_cached_slot_be_unflushed: bool, epoch_schedule: &EpochSchedule, rent_collector: &RentCollector, is_startup: bool ) -> (Hash, u64)

source

pub fn calculate_accounts_hash_without_index( &self, config: &CalcAccountsHashConfig<'_>, storages: &SortedStorages<'_>, stats: HashStats ) -> Result<(Hash, u64), BankHashVerificationError>

source

pub fn verify_bank_hash_and_lamports( &self, slot: Slot, ancestors: &Ancestors, total_lamports: u64, test_hash_calculation: bool, epoch_schedule: &EpochSchedule, rent_collector: &RentCollector, can_cached_slot_be_unflushed: bool, use_bg_thread_pool: bool ) -> Result<(), BankHashVerificationError>

Only called from startup or test code.

source

pub fn verify_bank_hash_and_lamports_new( &self, slot: Slot, ancestors: &Ancestors, total_lamports: u64, test_hash_calculation: bool, epoch_schedule: &EpochSchedule, rent_collector: &RentCollector, can_cached_slot_be_unflushed: bool, ignore_mismatch: bool, store_hash_raw_data_for_debug: bool, use_bg_thread_pool: bool ) -> Result<(), BankHashVerificationError>

Only called from startup or test code.

source

pub fn scan_slot_and_insert_dirty_pubkeys_into_uncleaned_pubkeys( &self, slot: Slot )

Scan a slot in the account storage for dirty pubkeys and insert them into the list of uncleaned pubkeys

This function is called in Bank::drop() when the bank is not frozen, so that its pubkeys are considered for cleanup.

source

pub fn get_accounts_delta_hash(&self, slot: Slot) -> Hash

source

pub fn get_accounts_delta_hash_with_rewrites( &self, slot: Slot, skipped_rewrites: &Rewrites ) -> Hash

source

pub fn store_cached<'a, T: ReadableAccount + Sync + ZeroLamport>( &self, accounts: impl StorableAccounts<'a, T>, txn_signatures: Option<&'a [Option<&'a Signature>]> )

source

pub fn store_uncached( &self, slot: Slot, accounts: &[(&Pubkey, &AccountSharedData)] )

Store the account update. only called by tests

source

pub fn add_root(&self, slot: Slot) -> AccountsAddRootTiming

source

pub fn get_snapshot_storages( &self, snapshot_slot: Slot, snapshot_base_slot: Option<Slot>, ancestors: Option<&Ancestors> ) -> (SnapshotStorages, Vec<Slot>)

source

pub fn is_filler_account_helper( pubkey: &Pubkey, filler_account_suffix: Option<&Pubkey> ) -> bool

source

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

true if ‘pubkey’ is a filler account

source

pub fn filler_accounts_enabled(&self) -> bool

true if it is possible that there are filler accounts present

source

pub fn maybe_add_filler_accounts( &self, epoch_schedule: &EpochSchedule, rent: &Rent, slot: Slot )

filler accounts are space-holding accounts which are ignored by hash calculations and rent. They are designed to allow a validator to run against a network successfully while simulating having many more accounts present. All filler accounts share a common pubkey suffix. The suffix is randomly generated per validator on startup. The filler accounts are added to each slot in the snapshot after index generation. The accounts added in a slot are setup to have pubkeys such that rent will be collected from them before (or when?) their slot becomes an epoch old. Thus, the filler accounts are rewritten by rent and the old slot can be thrown away successfully.

source

pub fn generate_index( &self, limit_load_slot_count_from_snapshot: Option<usize>, verify: bool, genesis_config: &GenesisConfig ) -> IndexGenerationInfo

source§

impl AccountsDb

Legacy shrink functions to support non-cached path. Should be able to be deleted after cache path is the only path.

Trait Implementations§

source§

impl Debug for AccountsDb

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> AbiExample for T

source§

default fn example() -> T

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · 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 Twhere U: From<T>,

const: unstable · 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.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

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

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

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

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
§

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

§

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