Type Alias StateCacheDb

Source
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>

pub fn new(db: ExtDB) -> CacheDB<ExtDB>

Creates a new cache with the given external database.

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)

Inserts account info but not override storage

pub fn nest(self) -> CacheDB<CacheDB<ExtDB>>

Wraps the cache in a CacheDB, creating a nested cache.

§

impl<ExtDB> CacheDB<ExtDB>
where ExtDB: DatabaseRef,

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>

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>

Replaces account storage without overriding account info

Trait Implementations

§

impl<ExtDB> Clone for CacheDB<ExtDB>
where ExtDB: Clone,

§

fn clone(&self) -> CacheDB<ExtDB>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

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>

Get the value in an account’s storage slot.

It is assumed that account is already loaded.

§

type Error = <ExtDB as DatabaseRef>::Error

The database error type.
§

fn basic( &mut self, address: Address, ) -> Result<Option<AccountInfo>, <CacheDB<ExtDB> as Database>::Error>

Gets basic account information.
§

fn code_by_hash( &mut self, code_hash: FixedBytes<32>, ) -> Result<Bytecode, <CacheDB<ExtDB> as Database>::Error>

Gets account code by its hash.
§

fn block_hash( &mut self, number: u64, ) -> Result<FixedBytes<32>, <CacheDB<ExtDB> as Database>::Error>

Gets block hash by block number.
§

impl<ExtDB> DatabaseCommit for CacheDB<ExtDB>

§

fn commit(&mut self, changes: HashMap<Address, Account, RandomState>)

Commit changes to the database.
§

impl<ExtDB> DatabaseRef for CacheDB<ExtDB>
where ExtDB: DatabaseRef,

§

type Error = <ExtDB as DatabaseRef>::Error

The database error type.
§

fn basic_ref( &self, address: Address, ) -> Result<Option<AccountInfo>, <CacheDB<ExtDB> as DatabaseRef>::Error>

Gets basic account information.
§

fn code_by_hash_ref( &self, code_hash: FixedBytes<32>, ) -> Result<Bytecode, <CacheDB<ExtDB> as DatabaseRef>::Error>

Gets account code by its hash.
§

fn storage_ref( &self, address: Address, index: Uint<256, 4>, ) -> Result<Uint<256, 4>, <CacheDB<ExtDB> as DatabaseRef>::Error>

Gets storage value of address at index.
§

fn block_hash_ref( &self, number: u64, ) -> Result<FixedBytes<32>, <CacheDB<ExtDB> as DatabaseRef>::Error>

Gets block hash by block number.
§

impl<ExtDB> Debug for CacheDB<ExtDB>
where ExtDB: Debug,

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl<ExtDB> Default for CacheDB<ExtDB>
where ExtDB: Default,

§

fn default() -> CacheDB<ExtDB>

Returns the “default value” for a type. Read more
§

impl<'de, ExtDB> Deserialize<'de> for CacheDB<ExtDB>
where ExtDB: Deserialize<'de>,

§

fn deserialize<__D>( __deserializer: __D, ) -> Result<CacheDB<ExtDB>, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<DB> OverrideBlockHashes for CacheDB<DB>

Source§

fn override_block_hashes(&mut self, block_hashes: BTreeMap<u64, FixedBytes<32>>)

Overrides the given block hashes.
§

impl<ExtDB> Serialize for CacheDB<ExtDB>
where ExtDB: Serialize,

§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more