Trait DatabaseRef
pub trait DatabaseRef {
type Error: DBErrorMarker;
// 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>;
// Provided method
fn storage_by_account_id_ref(
&self,
address: Address,
account_id: usize,
storage_key: Uint<256, 4>,
) -> Result<Uint<256, 4>, 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: DBErrorMarker
type Error: DBErrorMarker
The database error type.
Required Methods§
fn basic_ref(
&self,
address: Address,
) -> Result<Option<AccountInfo>, Self::Error>
fn basic_ref( &self, address: Address, ) -> Result<Option<AccountInfo>, Self::Error>
Gets basic account information.
fn code_by_hash_ref(
&self,
code_hash: FixedBytes<32>,
) -> Result<Bytecode, Self::Error>
fn code_by_hash_ref( &self, code_hash: FixedBytes<32>, ) -> Result<Bytecode, Self::Error>
Gets account code by its hash.
fn storage_ref(
&self,
address: Address,
index: Uint<256, 4>,
) -> Result<Uint<256, 4>, Self::Error>
fn storage_ref( &self, address: Address, index: Uint<256, 4>, ) -> Result<Uint<256, 4>, Self::Error>
Gets storage value of address at index.
fn block_hash_ref(&self, number: u64) -> Result<FixedBytes<32>, Self::Error>
fn block_hash_ref(&self, number: u64) -> Result<FixedBytes<32>, Self::Error>
Gets block hash by block number.
Provided Methods§
fn storage_by_account_id_ref(
&self,
address: Address,
account_id: usize,
storage_key: Uint<256, 4>,
) -> Result<Uint<256, 4>, Self::Error>
fn storage_by_account_id_ref( &self, address: Address, account_id: usize, storage_key: Uint<256, 4>, ) -> Result<Uint<256, 4>, Self::Error>
Gets storage value of account by its id.
Default implementation is to call DatabaseRef::storage_ref method.
Implementations on Foreign Types§
§impl<'a, T> DatabaseRef for &'a Twhere
T: 'a + DatabaseRef + ?Sized,
impl<'a, T> DatabaseRef for &'a Twhere
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 storage_by_account_id_ref( &self, address: Address, account_id: usize, storage_key: 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 Twhere
T: 'a + DatabaseRef + ?Sized,
impl<'a, T> DatabaseRef for &'a mut Twhere
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 storage_by_account_id_ref( &self, address: Address, account_id: usize, storage_key: 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<DB> DatabaseRef for CachedReadsDBRef<'_, DB>where
DB: DatabaseRef,
impl<DB> DatabaseRef for CachedReadsDBRef<'_, DB>where
DB: DatabaseRef,
type Error = <DB as DatabaseRef>::Error
fn basic_ref( &self, address: Address, ) -> Result<Option<AccountInfo>, <CachedReadsDBRef<'_, DB> as DatabaseRef>::Error>
fn code_by_hash_ref( &self, code_hash: FixedBytes<32>, ) -> Result<Bytecode, <CachedReadsDBRef<'_, DB> as DatabaseRef>::Error>
fn storage_ref( &self, address: Address, index: Uint<256, 4>, ) -> Result<Uint<256, 4>, <CachedReadsDBRef<'_, DB> as DatabaseRef>::Error>
fn block_hash_ref( &self, number: u64, ) -> Result<FixedBytes<32>, <CachedReadsDBRef<'_, DB> as DatabaseRef>::Error>
§impl<DB> DatabaseRef for StateProviderDatabase<DB>where
DB: EvmStateProvider,
impl<DB> DatabaseRef for StateProviderDatabase<DB>where
DB: EvmStateProvider,
§fn basic_ref(
&self,
address: Address,
) -> Result<Option<AccountInfo>, <StateProviderDatabase<DB> as DatabaseRef>::Error>
fn basic_ref( &self, address: Address, ) -> Result<Option<AccountInfo>, <StateProviderDatabase<DB> as DatabaseRef>::Error>
Retrieves basic account information for a given address.
Returns Ok with Some(AccountInfo) if the account exists,
None if it doesn’t, or an error if encountered.
§fn code_by_hash_ref(
&self,
code_hash: FixedBytes<32>,
) -> Result<Bytecode, <StateProviderDatabase<DB> as DatabaseRef>::Error>
fn code_by_hash_ref( &self, code_hash: FixedBytes<32>, ) -> Result<Bytecode, <StateProviderDatabase<DB> as DatabaseRef>::Error>
Retrieves the bytecode associated with a given code hash.
Returns Ok with the bytecode if found, or the default bytecode otherwise.
§fn storage_ref(
&self,
address: Address,
index: Uint<256, 4>,
) -> Result<Uint<256, 4>, <StateProviderDatabase<DB> as DatabaseRef>::Error>
fn storage_ref( &self, address: Address, index: Uint<256, 4>, ) -> Result<Uint<256, 4>, <StateProviderDatabase<DB> as DatabaseRef>::Error>
Retrieves the storage value at a specific index for a given address.
Returns Ok with the storage value, or the default value if not found.
§fn block_hash_ref(
&self,
number: u64,
) -> Result<FixedBytes<32>, <StateProviderDatabase<DB> as DatabaseRef>::Error>
fn block_hash_ref( &self, number: u64, ) -> Result<FixedBytes<32>, <StateProviderDatabase<DB> as DatabaseRef>::Error>
Retrieves the block hash for a given block number.
Returns Ok with the block hash if found, or the default hash otherwise.