Struct solana_runtime::accounts_db::AccountsDb
source · [−]pub struct AccountsDb {Show 14 fields
pub accounts_index: AccountsIndex<AccountInfo>,
pub storage: AccountStorage,
pub accounts_cache: AccountsCache,
pub read_only_accounts_cache: ReadOnlyAccountsCache,
pub next_id: AtomicUsize,
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 cluster_type: Option<ClusterType>,
pub account_indexes: AccountSecondaryIndexes,
pub caching_enabled: bool,
/* private fields */
}
Fields
accounts_index: AccountsIndex<AccountInfo>
Keeps tracks of index into AppendVec on a per slot basis
storage: AccountStorage
accounts_cache: AccountsCache
read_only_accounts_cache: ReadOnlyAccountsCache
next_id: AtomicUsize
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>>
cluster_type: Option<ClusterType>
account_indexes: AccountSecondaryIndexes
caching_enabled: bool
Implementations
sourceimpl AccountsDb
impl AccountsDb
sourcepub fn notify_account_restore_from_snapshot(&self)
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.
pub fn notify_account_at_accounts_update(
&self,
slot: Slot,
meta: &StoredMeta,
account: &AccountSharedData
)
sourceimpl AccountsDb
impl AccountsDb
pub fn new(paths: Vec<PathBuf>, cluster_type: &ClusterType) -> Self
pub fn new_for_tests_with_caching(
paths: Vec<PathBuf>,
cluster_type: &ClusterType
) -> Self
pub fn new_with_config(
paths: Vec<PathBuf>,
cluster_type: &ClusterType,
account_indexes: AccountSecondaryIndexes,
caching_enabled: bool,
shrink_ratio: AccountShrinkThreshold,
accounts_update_notifier: Option<AccountsUpdateNotifier>
) -> Self
pub fn set_shrink_paths(&self, paths: Vec<PathBuf>)
pub fn file_size(&self) -> u64
pub fn new_single() -> Self
pub fn new_single_for_tests_with_caching() -> Self
pub fn expected_cluster_type(&self) -> ClusterType
pub fn clean_accounts(&self, max_clean_root: Option<Slot>, is_startup: bool)
pub fn shrink_candidate_slots(&self) -> usize
pub fn shrink_all_slots(&self, is_startup: bool)
pub fn scan_accounts<F, A>(
&self,
ancestors: &Ancestors,
bank_id: BankId,
scan_func: F
) -> ScanResult<A> where
F: Fn(&mut A, Option<(&Pubkey, AccountSharedData, Slot)>),
A: Default,
pub fn unchecked_scan_accounts<F, A>(
&self,
metric_name: &'static str,
ancestors: &Ancestors,
scan_func: F
) -> A where
F: Fn(&mut A, (&Pubkey, LoadedAccount<'_>, Slot)),
A: Default,
pub fn range_scan_accounts<F, A, R>(
&self,
metric_name: &'static str,
ancestors: &Ancestors,
range: R,
scan_func: F
) -> A where
F: Fn(&mut A, Option<(&Pubkey, AccountSharedData, Slot)>),
A: Default,
R: RangeBounds<Pubkey>,
pub fn index_scan_accounts<F, A>(
&self,
ancestors: &Ancestors,
bank_id: BankId,
index_key: IndexKey,
scan_func: F
) -> ScanResult<(A, bool)> where
F: Fn(&mut A, Option<(&Pubkey, AccountSharedData, Slot)>),
A: Default,
sourcepub 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,
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
pub fn set_hash(&self, slot: Slot, parent_slot: Slot)
pub fn load(
&self,
ancestors: &Ancestors,
pubkey: &Pubkey,
load_hint: LoadHint
) -> Option<(AccountSharedData, Slot)>
pub fn load_with_fixed_root(
&self,
ancestors: &Ancestors,
pubkey: &Pubkey
) -> Option<(AccountSharedData, Slot)>
pub fn load_without_fixed_root(
&self,
ancestors: &Ancestors,
pubkey: &Pubkey
) -> Option<(AccountSharedData, Slot)>
pub fn load_account_hash(
&self,
ancestors: &Ancestors,
pubkey: &Pubkey,
max_root: Option<Slot>,
load_hint: LoadHint
) -> Option<Hash>
pub fn create_drop_bank_callback(
&self,
pruned_banks_sender: DroppedSlotsSender
) -> SendDroppedBankCallback
sourcepub fn purge_slot(&self, slot: Slot, bank_id: BankId, is_from_abs: bool)
pub fn purge_slot(&self, slot: Slot, bank_id: BankId, is_from_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_from_abs
is true if the caller is the AccountsBackgroundService
pub fn remove_unrooted_slots(&self, remove_slots: &[(Slot, BankId)])
pub fn hash_stored_account(slot: Slot, account: &StoredAccountMeta<'_>) -> Hash
pub fn hash_account<T: ReadableAccount>(
slot: Slot,
account: &T,
pubkey: &Pubkey
) -> Hash
pub fn mark_slot_frozen(&self, slot: Slot)
pub fn expire_old_recycle_stores(&self)
pub fn flush_accounts_cache(
&self,
force_flush: bool,
requested_flush_root: Option<Slot>
)
pub fn checked_iterative_sum_for_capitalization(
total_cap: u64,
new_cap: u64
) -> u64
pub fn checked_sum_for_capitalization<T: Iterator<Item = u64>>(
balances: T
) -> u64
pub fn get_accounts_hash(&self, slot: Slot) -> Hash
pub fn update_accounts_hash(
&self,
slot: Slot,
ancestors: &Ancestors
) -> (Hash, u64)
pub fn update_accounts_hash_test(
&self,
slot: Slot,
ancestors: &Ancestors
) -> (Hash, u64)
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,
slots_per_epoch: Option<Slot>
) -> (Hash, u64)
pub fn calculate_accounts_hash_without_index(
storages: &SortedStorages<'_>,
thread_pool: Option<&ThreadPool>,
stats: HashStats,
check_hash: bool,
accounts_cache_and_ancestors: Option<(&AccountsCache, &Ancestors, &AccountsIndex<AccountInfo>)>
) -> Result<(Hash, u64), BankHashVerificationError>
pub fn verify_bank_hash_and_lamports(
&self,
slot: Slot,
ancestors: &Ancestors,
total_lamports: u64,
test_hash_calculation: bool
) -> Result<(), BankHashVerificationError>
sourcepub fn scan_slot_and_insert_dirty_pubkeys_into_uncleaned_pubkeys(
&self,
slot: Slot
)
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.
pub fn get_accounts_delta_hash(&self, slot: Slot) -> Hash
pub fn store_cached(
&self,
slot: Slot,
accounts: &[(&Pubkey, &AccountSharedData)]
)
sourcepub fn store_uncached(
&self,
slot: Slot,
accounts: &[(&Pubkey, &AccountSharedData)]
)
pub fn store_uncached(
&self,
slot: Slot,
accounts: &[(&Pubkey, &AccountSharedData)]
)
Store the account update.
pub fn add_root(&self, slot: Slot) -> AccountsAddRootTiming
pub fn get_snapshot_storages(
&self,
snapshot_slot: Slot,
ancestors: Option<&Ancestors>
) -> (SnapshotStorages, Vec<Slot>)
pub fn generate_index(&self, limit_load_slot_count_from_snapshot: Option<usize>)
sourceimpl AccountsDb
impl AccountsDb
Legacy shrink functions to support non-cached path. Should be able to be deleted after cache path is the only path.
pub fn process_stale_slot_v1(&self) -> usize
Trait Implementations
sourceimpl Debug for AccountsDb
impl Debug for AccountsDb
Auto Trait Implementations
impl !RefUnwindSafe for AccountsDb
impl Send for AccountsDb
impl Sync for AccountsDb
impl Unpin for AccountsDb
impl !UnwindSafe for AccountsDb
Blanket Implementations
sourceimpl<T> AbiExample for T
impl<T> AbiExample for T
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more