Type Alias AlloyCacheDB

Source
pub(crate) type AlloyCacheDB = CacheDB<WrapDatabaseAsync<AlloyDB<Ethereum, DynProvider>>>;

Aliased Type§

struct AlloyCacheDB {
    pub cache: Cache,
    pub db: WrapDatabaseAsync<AlloyDB<Ethereum, DynProvider>>,
}

Fields§

§cache: Cache

The cache that stores all state changes.

§db: WrapDatabaseAsync<AlloyDB<Ethereum, DynProvider>>

The underlying database ([DatabaseRef]) that is used to load data.

Note: This is read-only, data is never written to this database.

Implementations

Source§

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

Source

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.

Source

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

Source

pub fn replace_account_storage( &mut self, address: Address, storage: HashMap<Uint<256, 4>, Uint<256, 4>>, ) -> Result<(), <ExtDB as DatabaseRef>::Error>

Replaces account storage without overriding account info

Source§

impl<ExtDB> CacheDB<ExtDB>

Source

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

Creates a new cache with the given external database.

Source

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.

Source

pub fn insert_account_info(&mut self, address: Address, info: AccountInfo)

Inserts account info but not override storage

Source

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

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

Trait Implementations

Source§

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

Source§

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

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

Source§

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.

Source§

type Error = <ExtDB as DatabaseRef>::Error

The database error type.
Source§

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

Gets basic account information.
Source§

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

Gets account code by its hash.
Source§

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

Gets block hash by block number.
Source§

impl<ExtDB> DatabaseCommit for CacheDB<ExtDB>

Source§

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

Commit changes to the database.
Source§

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

Source§

type Error = <ExtDB as DatabaseRef>::Error

The database error type.
Source§

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

Gets basic account information.
Source§

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

Gets account code by its hash.
Source§

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

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

Gets block hash by block number.
Source§

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

Source§

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

Formats the value using the given formatter. Read more
Source§

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

Source§

fn default() -> CacheDB<ExtDB>

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

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

Source§

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<ExtDB> Serialize for CacheDB<ExtDB>
where ExtDB: Serialize,

Source§

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