pub type StateCacheDb<'a> = CacheDB<StateProviderDatabase<StateProviderTraitObjWrapper<'a>>>;
Expand description
Helper alias type for the state’s CacheDB
Aliased Type§
struct StateCacheDb<'a> {
pub cache: Cache,
pub db: StateProviderDatabase<StateProviderTraitObjWrapper<'a>>,
}
Fields§
§cache: Cache
The cache that stores all state changes.
db: StateProviderDatabase<StateProviderTraitObjWrapper<'a>>
The underlying database (DatabaseRef) that is used to load data.
Note: This is read-only, data is never written to this database.
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 160 bytes
Implementations
§impl<ExtDB> CacheDB<ExtDB>
impl<ExtDB> CacheDB<ExtDB>
pub fn insert_contract(&mut self, account: &mut AccountInfo)
pub fn insert_contract(&mut self, account: &mut AccountInfo)
Inserts the account’s code into the cache.
Accounts objects and code are stored separately in the cache, this will take the code from the account and instead map it to the code hash.
Note: This will not insert into the underlying external database.
pub fn insert_account_info(&mut self, address: Address, info: AccountInfo)
pub fn insert_account_info(&mut self, address: Address, info: AccountInfo)
Inserts account info but not override storage
§impl<ExtDB> CacheDB<ExtDB>where
ExtDB: DatabaseRef,
impl<ExtDB> CacheDB<ExtDB>where
ExtDB: DatabaseRef,
pub fn load_account(
&mut self,
address: Address,
) -> Result<&mut DbAccount, <ExtDB as DatabaseRef>::Error>
pub fn load_account( &mut self, address: Address, ) -> Result<&mut DbAccount, <ExtDB as DatabaseRef>::Error>
Returns the account for the given address.
If the account was not found in the cache, it will be loaded from the underlying database.
pub fn insert_account_storage(
&mut self,
address: Address,
slot: Uint<256, 4>,
value: Uint<256, 4>,
) -> Result<(), <ExtDB as DatabaseRef>::Error>
pub fn insert_account_storage( &mut self, address: Address, slot: Uint<256, 4>, value: Uint<256, 4>, ) -> Result<(), <ExtDB as DatabaseRef>::Error>
Inserts account storage without overriding account info
pub fn replace_account_storage(
&mut self,
address: Address,
storage: HashMap<Uint<256, 4>, Uint<256, 4>, RandomState>,
) -> Result<(), <ExtDB as DatabaseRef>::Error>
pub fn replace_account_storage( &mut self, address: Address, storage: HashMap<Uint<256, 4>, Uint<256, 4>, RandomState>, ) -> Result<(), <ExtDB as DatabaseRef>::Error>
Replaces account storage without overriding account info
Trait Implementations
§impl<ExtDB> Database for CacheDB<ExtDB>where
ExtDB: DatabaseRef,
impl<ExtDB> Database for CacheDB<ExtDB>where
ExtDB: DatabaseRef,
§fn storage(
&mut self,
address: Address,
index: Uint<256, 4>,
) -> Result<Uint<256, 4>, <CacheDB<ExtDB> as Database>::Error>
fn storage( &mut self, address: Address, index: Uint<256, 4>, ) -> Result<Uint<256, 4>, <CacheDB<ExtDB> as Database>::Error>
Get the value in an account’s storage slot.
It is assumed that account is already loaded.