pub struct AccountStorage { /* private fields */ }Expand description
A simpler implementation of CacheDB that can’t query a node. It just stores data.
Implementations§
Source§impl AccountStorage
impl AccountStorage
pub fn new() -> Self
Sourcepub fn init_account(
&mut self,
address: Address,
info: AccountInfo,
permanent_storage: Option<HashMap<U256, U256>>,
mocked: bool,
)
pub fn init_account( &mut self, address: Address, info: AccountInfo, permanent_storage: Option<HashMap<U256, U256>>, mocked: bool, )
Inserts account data into the current instance.
§Arguments
address- The address of the account to insert.info- The account information to insert.permanent_storage- Optional storage information associated with the account.mocked- Whether this account should be considered mocked.
§Notes
This function checks if the address is already present in the accounts
collection. If so, it logs a warning and returns without modifying the instance.
Otherwise, it stores a new Account instance with the provided data at the given address.
Sourcepub fn update_account(&mut self, address: &Address, update: &StateUpdate)
pub fn update_account(&mut self, address: &Address, update: &StateUpdate)
Updates the account information and storage associated with the given address.
§Arguments
address- The address of the account to update.update- The state update containing the new information to apply.
§Notes
This function looks for the account information and storage associated with the provided
address. If the address exists in the accounts collection, it updates the account
information based on the balance field in the update parameter. If the address exists
in the storage collection, it updates the storage information based on the storage field
in the update parameter.
If the address is not found in either collection, a warning is logged and no changes are
made.
Sourcepub fn get_account_info(&self, address: &Address) -> Option<&AccountInfo>
pub fn get_account_info(&self, address: &Address) -> Option<&AccountInfo>
Retrieves the account information for a given address.
This function retrieves the account information associated with the specified address from the storage.
§Arguments
address: The address of the account to retrieve the information for.
§Returns
Returns an Option that holds a reference to the AccountInfo. If the account is not
found, None is returned.
Sourcepub fn account_present(&self, address: &Address) -> bool
pub fn account_present(&self, address: &Address) -> bool
Sourcepub fn set_temp_storage(&mut self, address: Address, index: U256, value: U256)
pub fn set_temp_storage(&mut self, address: Address, index: U256, value: U256)
Sets the storage value at the specified index for the given account.
If the account exists in the storage, the storage value at the specified index is updated.
If the account does not exist, a warning message is logged indicating an attempt to set
storage on an uninitialized account.
§Arguments
address: The address of the account to set the storage value for.index: The index of the storage value to set.value: The new value to set for the storage.
Sourcepub fn get_storage(&self, address: &Address, index: &U256) -> Option<U256>
pub fn get_storage(&self, address: &Address, index: &U256) -> Option<U256>
Retrieves the storage value at the specified index for the given account, if it exists.
If the account exists in the storage, the storage value at the specified index is returned
as a reference. Temp storage takes priority over permanent storage.
If the account does not exist, None is returned.
§Arguments
address: A reference to the address of the account to retrieve the storage value from.index: A reference to the index of the storage value to retrieve.
§Returns
Returns an Option containing a reference to the storage value if it exists, otherwise
returns None.
Sourcepub fn get_permanent_storage(
&self,
address: &Address,
index: &U256,
) -> Option<U256>
pub fn get_permanent_storage( &self, address: &Address, index: &U256, ) -> Option<U256>
Retrieves the permanent storage value for the given address and index.
If an account with the specified address exists in the account storage, this function retrieves the corresponding permanent storage value associated with the given index.
§Arguments
address- The address of the account.index- The index of the desired storage value.
Sourcepub fn clear_temp_storage(&mut self)
pub fn clear_temp_storage(&mut self)
Removes all temp storage values.
Iterates over the accounts in the storage and removes all temp storage values
Trait Implementations§
Source§impl Clone for AccountStorage
impl Clone for AccountStorage
Source§fn clone(&self) -> AccountStorage
fn clone(&self) -> AccountStorage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AccountStorage
impl Debug for AccountStorage
Source§impl Default for AccountStorage
impl Default for AccountStorage
Source§fn default() -> AccountStorage
fn default() -> AccountStorage
Auto Trait Implementations§
impl Freeze for AccountStorage
impl RefUnwindSafe for AccountStorage
impl Send for AccountStorage
impl Sync for AccountStorage
impl Unpin for AccountStorage
impl UnwindSafe for AccountStorage
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FmtForward for T
impl<T> FmtForward for T
Source§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self to use its Binary implementation when Debug-formatted.Source§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self to use its Display implementation when
Debug-formatted.Source§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self to use its LowerExp implementation when
Debug-formatted.Source§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self to use its LowerHex implementation when
Debug-formatted.Source§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self to use its Octal implementation when Debug-formatted.Source§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self to use its Pointer implementation when
Debug-formatted.Source§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self to use its UpperExp implementation when
Debug-formatted.Source§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self to use its UpperHex implementation when
Debug-formatted.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 moreSource§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
Source§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
Source§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self and passes that borrow into the pipe function. Read moreSource§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
Source§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
Source§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self, then passes self.as_ref() into the pipe function.Source§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self, then passes self.as_mut() into the pipe
function.Source§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self, then passes self.deref() into the pipe function.Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> Tap for T
impl<T> Tap for T
Source§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B> of a value. Read moreSource§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B> of a value. Read moreSource§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R> view of a value. Read moreSource§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R> view of a value. Read moreSource§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target of a value. Read moreSource§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap() only in debug builds, and is erased in release builds.Source§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow() only in debug builds, and is erased in release
builds.Source§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut() only in debug builds, and is erased in release
builds.Source§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref() only in debug builds, and is erased in release
builds.Source§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut() only in debug builds, and is erased in release
builds.Source§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref() only in debug builds, and is erased in release
builds.