pub trait Database: Send + Sync {
Show 14 methods
// Required methods
fn get_account_state(
&self,
address: Address,
) -> Result<AccountState, DatabaseError>;
fn get_storage_value(
&self,
address: Address,
key: H256,
) -> Result<U256, DatabaseError>;
fn get_block_hash(&self, block_number: u64) -> Result<H256, DatabaseError>;
fn get_chain_config(&self) -> Result<ChainConfig, DatabaseError>;
fn get_account_code(&self, code_hash: H256) -> Result<Code, DatabaseError>;
fn get_code_metadata(
&self,
code_hash: H256,
) -> Result<CodeMetadata, DatabaseError>;
// Provided methods
fn precompile_cache(&self) -> Option<&PrecompileCache> { ... }
fn get_account_states_batch(
&self,
addresses: &[Address],
) -> Result<Vec<AccountState>, DatabaseError> { ... }
fn get_account_codes_batch(
&self,
code_hashes: &[H256],
) -> Result<Vec<Option<Code>>, DatabaseError> { ... }
fn get_storage_values_batch(
&self,
keys: &[(Address, H256)],
) -> Result<Vec<U256>, DatabaseError> { ... }
fn code_cache_budget_bytes(&self) -> u64 { ... }
fn prefetch_codes(&self, code_hashes: &[H256]) -> Result<u64, DatabaseError> { ... }
fn prefetch_accounts(
&self,
addresses: &[Address],
) -> Result<(), DatabaseError> { ... }
fn prefetch_storage(
&self,
keys: &[(Address, H256)],
) -> Result<(), DatabaseError> { ... }
}Required Methods§
fn get_account_state( &self, address: Address, ) -> Result<AccountState, DatabaseError>
fn get_storage_value( &self, address: Address, key: H256, ) -> Result<U256, DatabaseError>
fn get_block_hash(&self, block_number: u64) -> Result<H256, DatabaseError>
fn get_chain_config(&self) -> Result<ChainConfig, DatabaseError>
fn get_account_code(&self, code_hash: H256) -> Result<Code, DatabaseError>
fn get_code_metadata( &self, code_hash: H256, ) -> Result<CodeMetadata, DatabaseError>
Provided Methods§
Sourcefn precompile_cache(&self) -> Option<&PrecompileCache>
fn precompile_cache(&self) -> Option<&PrecompileCache>
Access the precompile cache, if available at this database layer.
Sourcefn get_account_states_batch(
&self,
addresses: &[Address],
) -> Result<Vec<AccountState>, DatabaseError>
fn get_account_states_batch( &self, addresses: &[Address], ) -> Result<Vec<AccountState>, DatabaseError>
Batch lookup. Default: loop. Backends with a batched read path (e.g. rocksdb
multi_get_cf on the flat key-value table) should override this and the
caching layer above will dispatch to it.
Sourcefn get_account_codes_batch(
&self,
code_hashes: &[H256],
) -> Result<Vec<Option<Code>>, DatabaseError>
fn get_account_codes_batch( &self, code_hashes: &[H256], ) -> Result<Vec<Option<Code>>, DatabaseError>
Batch bytecode lookup, aligned to code_hashes. None means the hash is absent
from the database. Default: loop. Backends with a batched read path (e.g. rocksdb
multi_get_cf on the account-codes table) should override this; the caching layer
above dispatches to it from Self::prefetch_codes.
Sourcefn get_storage_values_batch(
&self,
keys: &[(Address, H256)],
) -> Result<Vec<U256>, DatabaseError>
fn get_storage_values_batch( &self, keys: &[(Address, H256)], ) -> Result<Vec<U256>, DatabaseError>
Batch storage-slot lookup. Default: loop. Backends with a batched read
path (e.g. rocksdb multi_get_cf on the storage flat key-value table)
should override this and the caching layer above will dispatch to it.
Sourcefn code_cache_budget_bytes(&self) -> u64
fn code_cache_budget_bytes(&self) -> u64
Byte budget for warming bytecode ahead of execution, as measured by Code::size.
Bounds the bytecode a block warm reads speculatively, since a block access list does not say which of its addresses were accessed for their code. Backends holding a bytecode cache report its capacity, which is how much the node was configured to keep resident; the default is the floor for a backend without one.
Sourcefn prefetch_codes(&self, code_hashes: &[H256]) -> Result<u64, DatabaseError>
fn prefetch_codes(&self, code_hashes: &[H256]) -> Result<u64, DatabaseError>
Prefetch a batch of bytecodes into the cache. Default: sequential fallback.
Returns the total Code::size warmed, so a caller warming a whole block can
hold itself to Self::code_cache_budget_bytes. An absent hash is not an error:
warming has nothing to do for it and the executor reports it if reached.
Sourcefn prefetch_accounts(&self, addresses: &[Address]) -> Result<(), DatabaseError>
fn prefetch_accounts(&self, addresses: &[Address]) -> Result<(), DatabaseError>
Prefetch a batch of accounts into the cache. Default: sequential fallback.
Sourcefn prefetch_storage(
&self,
keys: &[(Address, H256)],
) -> Result<(), DatabaseError>
fn prefetch_storage( &self, keys: &[(Address, H256)], ) -> Result<(), DatabaseError>
Prefetch a batch of storage slots into the cache. Default: sequential fallback.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".