Struct solana_runtime::accounts::Accounts
source · [−]pub struct Accounts {
pub accounts_db: Arc<AccountsDb>,
/* private fields */
}
Expand description
This structure handles synchronization for db
Fields
accounts_db: Arc<AccountsDb>
Single global AccountsDb
Implementations
sourceimpl Accounts
impl Accounts
pub fn new(
paths: Vec<PathBuf>,
cluster_type: &ClusterType,
shrink_ratio: AccountShrinkThreshold
) -> 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 new_from_parent(parent: &Accounts, slot: Slot, parent_slot: Slot) -> Self
sourcepub fn has_duplicates<T: PartialEq>(xs: &[T]) -> bool
pub fn has_duplicates<T: PartialEq>(xs: &[T]) -> bool
Return true if the slice has any duplicate elements
pub fn load_accounts<'a>(
&self,
ancestors: &Ancestors,
txs: impl Iterator<Item = &'a Transaction>,
lock_results: Vec<TransactionCheckResult>,
hash_queue: &BlockhashQueue,
error_counters: &mut ErrorCounters,
rent_collector: &RentCollector,
feature_set: &FeatureSet
) -> Vec<TransactionLoadResult>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
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)>
sourcepub fn scan_slot<F, B>(&self, slot: Slot, func: F) -> Vec<B>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
where
F: Fn(LoadedAccount<'_>) -> Option<B> + Send + Sync,
B: Sync + Send + Default + Eq,
pub fn scan_slot<F, B>(&self, slot: Slot, func: F) -> Vec<B>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
where
F: Fn(LoadedAccount<'_>) -> Option<B> + Send + Sync,
B: Sync + Send + Default + Eq,
A: Allocator,
scans underlying accounts_db for this delta (slot) with a map function from LoadedAccount to B returns only the latest/current version of B for this slot
pub fn load_by_program_slot(
&self,
slot: Slot,
program_id: Option<&Pubkey>
) -> Vec<(Pubkey, AccountSharedData)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
pub fn load_largest_accounts(
&self,
ancestors: &Ancestors,
bank_id: BankId,
num: usize,
filter_by_address: &HashSet<Pubkey>,
filter: AccountAddressFilter
) -> ScanResult<Vec<(Pubkey, u64)>>
pub fn calculate_capitalization(
&self,
ancestors: &Ancestors,
slot: Slot,
can_cached_slot_be_unflushed: bool,
debug_verify: bool
) -> u64
pub fn verify_bank_hash_and_lamports(
&self,
slot: Slot,
ancestors: &Ancestors,
total_lamports: u64,
test_hash_calculation: bool
) -> bool
pub fn load_by_program(
&self,
ancestors: &Ancestors,
bank_id: BankId,
program_id: &Pubkey
) -> ScanResult<Vec<(Pubkey, AccountSharedData)>>
pub fn load_by_program_with_filter<F: Fn(&AccountSharedData) -> bool>(
&self,
ancestors: &Ancestors,
bank_id: BankId,
program_id: &Pubkey,
filter: F
) -> ScanResult<Vec<(Pubkey, AccountSharedData)>>
pub fn load_by_index_key_with_filter<F: Fn(&AccountSharedData) -> bool>(
&self,
ancestors: &Ancestors,
bank_id: BankId,
index_key: &IndexKey,
filter: F
) -> ScanResult<Vec<(Pubkey, AccountSharedData)>>
pub fn account_indexes_include_key(&self, key: &Pubkey) -> bool
pub fn load_all(
&self,
ancestors: &Ancestors,
bank_id: BankId
) -> ScanResult<Vec<(Pubkey, AccountSharedData, Slot)>>
pub fn load_to_collect_rent_eagerly<R: RangeBounds<Pubkey>>(
&self,
ancestors: &Ancestors,
range: R
) -> Vec<(Pubkey, AccountSharedData)>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
sourcepub fn store_slow_uncached(
&self,
slot: Slot,
pubkey: &Pubkey,
account: &AccountSharedData
)
pub fn store_slow_uncached(
&self,
slot: Slot,
pubkey: &Pubkey,
account: &AccountSharedData
)
Slow because lock is held for 1 operation instead of many. WARNING: This noncached version is only to be used for tests/benchmarking as bypassing the cache in general is not supported
pub fn store_slow_cached(
&self,
slot: Slot,
pubkey: &Pubkey,
account: &AccountSharedData
)
pub fn bank_hash_at(&self, slot: Slot) -> Hash
pub fn bank_hash_info_at(&self, slot: Slot) -> BankHashInfo
sourcepub fn lock_accounts<'a>(
&self,
txs: impl Iterator<Item = &'a Transaction>,
demote_program_write_locks: bool
) -> Vec<Result<()>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
pub fn lock_accounts<'a>(
&self,
txs: impl Iterator<Item = &'a Transaction>,
demote_program_write_locks: bool
) -> Vec<Result<()>>ⓘNotable traits for Vec<u8, A>impl<A> Write for Vec<u8, A> where
A: Allocator,
A: Allocator,
This function will prevent multiple threads from modifying the same account state at the same time
sourcepub fn unlock_accounts<'a>(
&self,
txs: impl Iterator<Item = &'a Transaction>,
results: &[Result<()>],
demote_program_write_locks: bool
)
pub fn unlock_accounts<'a>(
&self,
txs: impl Iterator<Item = &'a Transaction>,
results: &[Result<()>],
demote_program_write_locks: bool
)
Once accounts are unlocked, new transactions that modify that state can enter the pipeline
sourcepub fn store_cached<'a>(
&self,
slot: Slot,
txs: impl Iterator<Item = &'a Transaction>,
res: &'a [TransactionExecutionResult],
loaded: &'a mut [TransactionLoadResult],
rent_collector: &RentCollector,
last_blockhash_with_fee_calculator: &(Hash, FeeCalculator),
fix_recent_blockhashes_sysvar_delay: bool,
rent_for_sysvars: bool,
merge_nonce_error_into_system_error: bool,
demote_program_write_locks: bool
)
pub fn store_cached<'a>(
&self,
slot: Slot,
txs: impl Iterator<Item = &'a Transaction>,
res: &'a [TransactionExecutionResult],
loaded: &'a mut [TransactionLoadResult],
rent_collector: &RentCollector,
last_blockhash_with_fee_calculator: &(Hash, FeeCalculator),
fix_recent_blockhashes_sysvar_delay: bool,
rent_for_sysvars: bool,
merge_nonce_error_into_system_error: bool,
demote_program_write_locks: bool
)
Store the accounts into the DB
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)
Purge a slot if it is not a root
Root slots cannot be purged
is_from_abs
is true if the caller is the AccountsBackgroundService
sourcepub fn add_root(&self, slot: Slot) -> AccountsAddRootTiming
pub fn add_root(&self, slot: Slot) -> AccountsAddRootTiming
Add a slot to root. Root slots cannot be purged
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Accounts
impl Send for Accounts
impl Sync for Accounts
impl Unpin for Accounts
impl !UnwindSafe for Accounts
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