Trait Database
pub trait Database: NonStaticAny {
type Error: Error + Send + Sync + 'static;
// Required methods
fn get_account(
&mut self,
address: &Address,
) -> Result<Option<AccountInfo>, Self::Error>;
fn get_code_by_hash(
&mut self,
code_hash: &FixedBytes<32>,
) -> Result<Bytecode, Self::Error>;
fn get_storage(
&mut self,
address: &Address,
key: &Uint<256, 4>,
) -> Result<Uint<256, 4>, Self::Error>;
fn get_block_hash(
&mut self,
number: &Uint<256, 4>,
) -> Result<FixedBytes<32>, Self::Error>;
// Provided method
fn is_fatal(error: &Self::Error) -> bool { ... }
}Available on crate feature
evm only.Expand description
Backing database implementation with a concrete error type.
Required Associated Types§
Required Methods§
fn get_account(
&mut self,
address: &Address,
) -> Result<Option<AccountInfo>, Self::Error>
fn get_account( &mut self, address: &Address, ) -> Result<Option<AccountInfo>, Self::Error>
Loads account information.
fn get_code_by_hash(
&mut self,
code_hash: &FixedBytes<32>,
) -> Result<Bytecode, Self::Error>
fn get_code_by_hash( &mut self, code_hash: &FixedBytes<32>, ) -> Result<Bytecode, Self::Error>
Loads bytecode by code hash.
fn get_storage(
&mut self,
address: &Address,
key: &Uint<256, 4>,
) -> Result<Uint<256, 4>, Self::Error>
fn get_storage( &mut self, address: &Address, key: &Uint<256, 4>, ) -> Result<Uint<256, 4>, Self::Error>
Loads a persistent storage slot.
fn get_block_hash(
&mut self,
number: &Uint<256, 4>,
) -> Result<FixedBytes<32>, Self::Error>
fn get_block_hash( &mut self, number: &Uint<256, 4>, ) -> Result<FixedBytes<32>, Self::Error>
Loads a historical block hash.
Callers only request numbers inside the BLOCKHASH window, so a hash the database cannot
provide is a database failure reported through the error, never a benign miss.
Provided Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
§impl<'a, T> Database for &'a mut T
impl<'a, T> Database for &'a mut T
type Error = <T as Database>::Error
fn is_fatal(error: &<&'a mut T as Database>::Error) -> bool
fn get_account( &mut self, address: &Address, ) -> Result<Option<AccountInfo>, <&'a mut T as Database>::Error>
fn get_code_by_hash( &mut self, code_hash: &FixedBytes<32>, ) -> Result<Bytecode, <&'a mut T as Database>::Error>
fn get_storage( &mut self, address: &Address, key: &Uint<256, 4>, ) -> Result<Uint<256, 4>, <&'a mut T as Database>::Error>
fn get_block_hash( &mut self, number: &Uint<256, 4>, ) -> Result<FixedBytes<32>, <&'a mut T as Database>::Error>
§impl<T> Database for Box<T>
impl<T> Database for Box<T>
type Error = <T as Database>::Error
fn is_fatal(error: &<Box<T> as Database>::Error) -> bool
fn get_account( &mut self, address: &Address, ) -> Result<Option<AccountInfo>, <Box<T> as Database>::Error>
fn get_code_by_hash( &mut self, code_hash: &FixedBytes<32>, ) -> Result<Bytecode, <Box<T> as Database>::Error>
fn get_storage( &mut self, address: &Address, key: &Uint<256, 4>, ) -> Result<Uint<256, 4>, <Box<T> as Database>::Error>
fn get_block_hash( &mut self, number: &Uint<256, 4>, ) -> Result<FixedBytes<32>, <Box<T> as Database>::Error>
Implementors§
Source§impl<DB> Database for CachedReadsDbMut<'_, DB>where
DB: Database,
impl<DB> Database for CachedReadsDbMut<'_, DB>where
DB: Database,
Source§impl<DB> Database for StateProviderDatabase<DB>where
DB: EvmStateProvider,
Available on crate feature std only.
impl<DB> Database for StateProviderDatabase<DB>where
DB: EvmStateProvider,
Available on crate feature
std only.