anvil::eth::backend::mem::in_memory_db

Trait DatabaseRef

pub trait DatabaseRef {
    type Error;

    // Required methods
    fn basic_ref(
        &self,
        address: Address,
    ) -> Result<Option<AccountInfo>, Self::Error>;
    fn code_by_hash_ref(
        &self,
        code_hash: FixedBytes<32>,
    ) -> Result<Bytecode, Self::Error>;
    fn storage_ref(
        &self,
        address: Address,
        index: Uint<256, 4>,
    ) -> Result<Uint<256, 4>, Self::Error>;
    fn block_hash_ref(&self, number: u64) -> Result<FixedBytes<32>, Self::Error>;
}
Expand description

EVM database interface.

Contains the same methods as [Database], but with &self receivers instead of &mut self.

Use [WrapDatabaseRef] to provide [Database] implementation for a type that only implements this trait.

Required Associated Types§

type Error

The database error type.

Required Methods§

fn basic_ref( &self, address: Address, ) -> Result<Option<AccountInfo>, Self::Error>

Get basic account information.

fn code_by_hash_ref( &self, code_hash: FixedBytes<32>, ) -> Result<Bytecode, Self::Error>

Get account code by its hash.

fn storage_ref( &self, address: Address, index: Uint<256, 4>, ) -> Result<Uint<256, 4>, Self::Error>

Get storage value of address at index.

fn block_hash_ref(&self, number: u64) -> Result<FixedBytes<32>, Self::Error>

Get block hash by block number.

Implementations on Foreign Types§

Source§

impl DatabaseRef for CowBackend<'_>

Source§

type Error = DatabaseError

Source§

fn basic_ref( &self, address: Address, ) -> Result<Option<AccountInfo>, <CowBackend<'_> as DatabaseRef>::Error>

Source§

fn code_by_hash_ref( &self, code_hash: FixedBytes<32>, ) -> Result<Bytecode, <CowBackend<'_> as DatabaseRef>::Error>

Source§

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

Source§

fn block_hash_ref( &self, number: u64, ) -> Result<FixedBytes<32>, <CowBackend<'_> as DatabaseRef>::Error>

Source§

impl DatabaseRef for EmptyDBWrapper

Source§

type Error = DatabaseError

Source§

fn basic_ref( &self, _address: Address, ) -> Result<Option<AccountInfo>, <EmptyDBWrapper as DatabaseRef>::Error>

Source§

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

Source§

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

Source§

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

Source§

impl DatabaseRef for Backend

Source§

type Error = DatabaseError

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl DatabaseRef for ForkDbStateSnapshot

Source§

type Error = DatabaseError

Source§

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

Source§

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

Source§

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

Source§

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

§

impl DatabaseRef for SharedBackend

§

type Error = DatabaseError

§

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

§

fn code_by_hash_ref( &self, hash: FixedBytes<32>, ) -> Result<Bytecode, <SharedBackend as DatabaseRef>::Error>

§

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

§

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

§

impl<'a, T> DatabaseRef for &'a T
where T: 'a + DatabaseRef + ?Sized,

§

type Error = <T as DatabaseRef>::Error

§

fn basic_ref( &self, address: Address, ) -> Result<Option<AccountInfo>, <&'a T as DatabaseRef>::Error>

§

fn code_by_hash_ref( &self, code_hash: FixedBytes<32>, ) -> Result<Bytecode, <&'a T as DatabaseRef>::Error>

§

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

§

fn block_hash_ref( &self, number: u64, ) -> Result<FixedBytes<32>, <&'a T as DatabaseRef>::Error>

§

impl<'a, T> DatabaseRef for &'a mut T
where T: 'a + DatabaseRef + ?Sized,

§

type Error = <T as DatabaseRef>::Error

§

fn basic_ref( &self, address: Address, ) -> Result<Option<AccountInfo>, <&'a mut T as DatabaseRef>::Error>

§

fn code_by_hash_ref( &self, code_hash: FixedBytes<32>, ) -> Result<Bytecode, <&'a mut T as DatabaseRef>::Error>

§

fn storage_ref( &self, address: Address, index: Uint<256, 4>, ) -> Result<Uint<256, 4>, <&'a mut T as DatabaseRef>::Error>

§

fn block_hash_ref( &self, number: u64, ) -> Result<FixedBytes<32>, <&'a mut T as DatabaseRef>::Error>

§

impl<E> DatabaseRef for EmptyDBTyped<E>

§

type Error = E

§

fn basic_ref( &self, _address: Address, ) -> Result<Option<AccountInfo>, <EmptyDBTyped<E> as DatabaseRef>::Error>

§

fn code_by_hash_ref( &self, _code_hash: FixedBytes<32>, ) -> Result<Bytecode, <EmptyDBTyped<E> as DatabaseRef>::Error>

§

fn storage_ref( &self, _address: Address, _index: Uint<256, 4>, ) -> Result<Uint<256, 4>, <EmptyDBTyped<E> as DatabaseRef>::Error>

§

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

§

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

§

type Error = <ExtDB as DatabaseRef>::Error

§

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

§

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

§

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

§

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

§

impl<T> DatabaseRef for Box<T>
where T: DatabaseRef + ?Sized,

§

type Error = <T as DatabaseRef>::Error

§

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

§

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

§

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

§

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

§

impl<T> DatabaseRef for Rc<T>
where T: DatabaseRef + ?Sized,

§

type Error = <T as DatabaseRef>::Error

§

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

§

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

§

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

§

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

§

impl<T> DatabaseRef for Arc<T>
where T: DatabaseRef + ?Sized,

§

type Error = <T as DatabaseRef>::Error

§

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

§

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

§

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

§

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

Implementors§

Source§

impl DatabaseRef for StateDb

Source§

type Error = DatabaseError

Source§

impl DatabaseRef for ForkedDatabase

Source§

type Error = DatabaseError

Source§

impl DatabaseRef for MemDb

Source§

type Error = DatabaseError

§

impl<S, BH> DatabaseRef for DatabaseComponents<S, BH>
where S: StateRef, BH: BlockHashRef,

§

type Error = DatabaseComponentError<<S as StateRef>::Error, <BH as BlockHashRef>::Error>