Skip to main content

Database

Trait Database 

Source
pub trait Database {
    type Error: DBErrorMarker;

    // Required methods
    fn basic(
        &mut self,
        address: Address,
    ) -> Result<Option<AccountInfo>, Self::Error>;
    fn code_by_hash(&mut self, code_hash: B256) -> Result<Bytecode, Self::Error>;
    fn storage(
        &mut self,
        address: Address,
        index: StorageKey,
    ) -> Result<StorageValue, Self::Error>;
    fn block_hash(&mut self, number: u64) -> Result<B256, Self::Error>;

    // Provided method
    fn storage_by_account_id(
        &mut self,
        address: Address,
        account_id: AccountId,
        storage_key: StorageKey,
    ) -> Result<StorageValue, Self::Error> { ... }
}
Expand description

EVM database interface.

Required Associated Types§

Source

type Error: DBErrorMarker

The database error type.

Required Methods§

Source

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

Gets basic account information.

Source

fn code_by_hash(&mut self, code_hash: B256) -> Result<Bytecode, Self::Error>

Gets account code by its hash.

Source

fn storage( &mut self, address: Address, index: StorageKey, ) -> Result<StorageValue, Self::Error>

Gets storage value of address at index.

Source

fn block_hash(&mut self, number: u64) -> Result<B256, Self::Error>

Gets block hash by block number.

Provided Methods§

Source

fn storage_by_account_id( &mut self, address: Address, account_id: AccountId, storage_key: StorageKey, ) -> Result<StorageValue, Self::Error>

Gets storage value of account by its id. By default call Database::storage method.

If basic account sets account_id inside AccountInfo::account_id, evm will call this function with that given account_id. This can be useful if IndexMap is used to get faster access to the account.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

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

Source§

type Error = <T as Database>::Error

Source§

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

Source§

fn code_by_hash(&mut self, code_hash: B256) -> Result<Bytecode, Self::Error>

Source§

fn storage( &mut self, address: Address, index: StorageKey, ) -> Result<StorageValue, Self::Error>

Source§

fn storage_by_account_id( &mut self, address: Address, account_id: AccountId, storage_key: StorageKey, ) -> Result<StorageValue, Self::Error>

Source§

fn block_hash(&mut self, number: u64) -> Result<B256, Self::Error>

Source§

impl<L, R> Database for Either<L, R>
where L: Database, R: Database<Error = L::Error>,

Source§

type Error = <L as Database>::Error

Source§

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

Source§

fn code_by_hash(&mut self, code_hash: B256) -> Result<Bytecode, Self::Error>

Source§

fn storage( &mut self, address: Address, index: StorageKey, ) -> Result<StorageValue, Self::Error>

Source§

fn block_hash(&mut self, number: u64) -> Result<B256, Self::Error>

Source§

fn storage_by_account_id( &mut self, address: Address, account_id: AccountId, storage_key: StorageKey, ) -> Result<StorageValue, Self::Error>

Source§

impl<T: Database + ?Sized> Database for Box<T>

Source§

type Error = <T as Database>::Error

Source§

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

Source§

fn code_by_hash(&mut self, code_hash: B256) -> Result<Bytecode, Self::Error>

Source§

fn storage( &mut self, address: Address, index: StorageKey, ) -> Result<StorageValue, Self::Error>

Source§

fn storage_by_account_id( &mut self, address: Address, account_id: AccountId, storage_key: StorageKey, ) -> Result<StorageValue, Self::Error>

Source§

fn block_hash(&mut self, number: u64) -> Result<B256, Self::Error>

Implementors§