Skip to main content

Database

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 { ... }
}
Expand description

Backing database implementation with a concrete error type.

Required Associated Types§

type Error: Error + Send + Sync + 'static

Database error type.

Required Methods§

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>

Loads bytecode by code hash.

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>

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§

fn is_fatal(error: &Self::Error) -> bool

Whether a concrete database error is an internal failure rather than invalid input.

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
where T: 'a + Database + ?Sized, &'a mut T: NonStaticAny,

§

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>
where T: Database + ?Sized, Box<T>: NonStaticAny,

§

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§

§

impl Database for EmptyDB

§

type Error = !

Source§

impl<DB: Database> Database for CachedReadsDbMut<'_, DB>

Source§

type Error = <DB as Database>::Error

Source§

impl<DB> Database for StateProviderDatabase<DB>
where DB: EvmStateProvider,

Available on crate feature std only.
Source§

type Error = ProviderError

§

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

§

type Error = DatabaseError