pub enum AccountsFile {
AppendVec(AppendVec),
TieredStorage(TieredStorage),
}
Expand description
An enum for accessing an accounts file which can be implemented under different formats.
Variants§
AppendVec(AppendVec)
TieredStorage(TieredStorage)
Implementations§
Source§impl AccountsFile
impl AccountsFile
Sourcepub fn new_for_startup(
path: impl Into<PathBuf>,
current_len: usize,
storage_access: StorageAccess,
) -> Result<Self>
pub fn new_for_startup( path: impl Into<PathBuf>, current_len: usize, storage_access: StorageAccess, ) -> Result<Self>
Creates a new AccountsFile for the underlying storage at path
This version of new()
may only be called when reconstructing storages as part of startup.
It trusts the snapshot’s value for current_len
, and relies on later index generation or
accounts verification to ensure it is valid.
pub fn flush(&self) -> Result<()>
pub fn reset(&self)
pub fn remaining_bytes(&self) -> u64
pub fn len(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn capacity(&self) -> u64
pub fn file_name(slot: Slot, id: AccountsFileId) -> String
Sourcepub fn get_stored_account_without_data_callback<Ret>(
&self,
offset: usize,
callback: impl for<'local> FnMut(StoredAccountInfoWithoutData<'local>) -> Ret,
) -> Option<Ret>
pub fn get_stored_account_without_data_callback<Ret>( &self, offset: usize, callback: impl for<'local> FnMut(StoredAccountInfoWithoutData<'local>) -> Ret, ) -> Option<Ret>
Calls callback
with the stored account at offset
.
Returns None
if there is no account at offset
, otherwise returns the result of
callback
in Some
.
This fn does not load the account’s data, just the data length. If the data is needed,
use get_stored_account_callback()
instead. However, prefer this fn when possible.
Sourcepub fn get_stored_account_callback<Ret>(
&self,
offset: usize,
callback: impl for<'local> FnMut(StoredAccountInfo<'local>) -> Ret,
) -> Option<Ret>
pub fn get_stored_account_callback<Ret>( &self, offset: usize, callback: impl for<'local> FnMut(StoredAccountInfo<'local>) -> Ret, ) -> Option<Ret>
Calls callback
with the stored account at offset
.
Returns None
if there is no account at offset
, otherwise returns the result of
callback
in Some
.
This fn does load the account’s data. If the data is not needed,
use get_stored_account_without_data_callback()
instead.
Sourcepub fn scan_accounts_without_data(
&self,
callback: impl for<'local> FnMut(Offset, StoredAccountInfoWithoutData<'local>),
) -> Result<()>
pub fn scan_accounts_without_data( &self, callback: impl for<'local> FnMut(Offset, StoredAccountInfoWithoutData<'local>), ) -> Result<()>
Iterate over all accounts and call callback
with each account.
callback
parameters:
- Offset: the offset within the file of this account
- StoredAccountInfoWithoutData: the account itself, without account data
Note that account data is not read/passed to the callback.
Sourcepub fn scan_pubkeys(&self, callback: impl FnMut(&Pubkey)) -> Result<()>
pub fn scan_pubkeys(&self, callback: impl FnMut(&Pubkey)) -> Result<()>
iterate over all pubkeys
Sourcepub fn write_accounts<'a>(
&self,
accounts: &impl StorableAccounts<'a>,
skip: usize,
) -> Option<StoredAccountsInfo>
pub fn write_accounts<'a>( &self, accounts: &impl StorableAccounts<'a>, skip: usize, ) -> Option<StoredAccountsInfo>
Copy each account metadata, account and hash to the internal buffer.
If there is no room to write the first entry, None is returned.
Otherwise, returns the starting offset of each account metadata.
Plus, the final return value is the offset where the next entry would be appended.
So, return.len() is 1 + (number of accounts written)
After each account is appended, the internal current_len
is updated
and will be available to other threads.
Sourcepub fn internals_for_archive(&self) -> InternalsForArchive<'_>
pub fn internals_for_archive(&self) -> InternalsForArchive<'_>
Returns the way to access this accounts file when archiving
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for AccountsFile
impl RefUnwindSafe for AccountsFile
impl Send for AccountsFile
impl Sync for AccountsFile
impl Unpin for AccountsFile
impl UnwindSafe for AccountsFile
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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