pub trait Db:
DatabaseRef<Error = DatabaseError>
+ Database<Error = DatabaseError>
+ DatabaseCommit
+ MaybeFullDatabase
+ MaybeForkedDatabase
+ Debug
+ Send
+ Sync {
// Required methods
fn insert_account(&mut self, address: Address, account: AccountInfo);
fn set_storage_at(
&mut self,
address: Address,
slot: B256,
val: B256,
) -> DatabaseResult<()>;
fn insert_block_hash(&mut self, number: U256, hash: B256);
fn dump_state(
&self,
at: BlockEnv,
best_number: u64,
blocks: Vec<SerializableBlock>,
transactions: Vec<SerializableTransaction>,
historical_states: Option<SerializableHistoricalStates>,
) -> DatabaseResult<Option<SerializableState>>;
fn snapshot_state(&mut self) -> U256;
fn revert_state(
&mut self,
state_snapshot: U256,
action: RevertStateSnapshotAction,
) -> bool;
fn current_state(&self) -> StateDb;
// Provided methods
fn set_nonce(&mut self, address: Address, nonce: u64) -> DatabaseResult<()> { ... }
fn set_balance(
&mut self,
address: Address,
balance: U256,
) -> DatabaseResult<()> { ... }
fn set_code(&mut self, address: Address, code: Bytes) -> DatabaseResult<()> { ... }
fn load_state(&mut self, state: SerializableState) -> DatabaseResult<bool> { ... }
fn maybe_state_root(&self) -> Option<B256> { ... }
}Expand description
This bundles all required revm traits
Required Methods§
Sourcefn insert_account(&mut self, address: Address, account: AccountInfo)
fn insert_account(&mut self, address: Address, account: AccountInfo)
Inserts an account
Sourcefn set_storage_at(
&mut self,
address: Address,
slot: B256,
val: B256,
) -> DatabaseResult<()>
fn set_storage_at( &mut self, address: Address, slot: B256, val: B256, ) -> DatabaseResult<()>
Sets the storage value at the given slot for the address
Sourcefn insert_block_hash(&mut self, number: U256, hash: B256)
fn insert_block_hash(&mut self, number: U256, hash: B256)
inserts a blockhash for the given number
Sourcefn dump_state(
&self,
at: BlockEnv,
best_number: u64,
blocks: Vec<SerializableBlock>,
transactions: Vec<SerializableTransaction>,
historical_states: Option<SerializableHistoricalStates>,
) -> DatabaseResult<Option<SerializableState>>
fn dump_state( &self, at: BlockEnv, best_number: u64, blocks: Vec<SerializableBlock>, transactions: Vec<SerializableTransaction>, historical_states: Option<SerializableHistoricalStates>, ) -> DatabaseResult<Option<SerializableState>>
Write all chain data to serialized bytes buffer
Sourcefn snapshot_state(&mut self) -> U256
fn snapshot_state(&mut self) -> U256
Creates a new state snapshot.
Sourcefn revert_state(
&mut self,
state_snapshot: U256,
action: RevertStateSnapshotAction,
) -> bool
fn revert_state( &mut self, state_snapshot: U256, action: RevertStateSnapshotAction, ) -> bool
Reverts a state snapshot.
Returns true if the state snapshot was reverted.
Sourcefn current_state(&self) -> StateDb
fn current_state(&self) -> StateDb
Returns the current, standalone state of the Db
Provided Methods§
Sourcefn set_nonce(&mut self, address: Address, nonce: u64) -> DatabaseResult<()>
fn set_nonce(&mut self, address: Address, nonce: u64) -> DatabaseResult<()>
Sets the nonce of the given address
Sourcefn set_balance(&mut self, address: Address, balance: U256) -> DatabaseResult<()>
fn set_balance(&mut self, address: Address, balance: U256) -> DatabaseResult<()>
Sets the balance of the given address
Sourcefn set_code(&mut self, address: Address, code: Bytes) -> DatabaseResult<()>
fn set_code(&mut self, address: Address, code: Bytes) -> DatabaseResult<()>
Sets the code of the given address
Sourcefn load_state(&mut self, state: SerializableState) -> DatabaseResult<bool>
fn load_state(&mut self, state: SerializableState) -> DatabaseResult<bool>
Deserialize and add all chain data to the backend storage
Sourcefn maybe_state_root(&self) -> Option<B256>
fn maybe_state_root(&self) -> Option<B256>
Returns the state root if possible to compute
Trait Implementations§
impl DatabaseRef for dyn Db
Implementations on Foreign Types§
Source§impl<T: DatabaseRef<Error = DatabaseError> + Send + Sync + Clone + Debug> Db for CacheDB<T>
Convenience impl only used to use any Db on the fly as the db layer for revm’s CacheDB
This is useful to create blocks without actually writing to the Db, but rather in the cache of
the CacheDB see also
Backend::pending_block()
impl<T: DatabaseRef<Error = DatabaseError> + Send + Sync + Clone + Debug> Db for CacheDB<T>
Convenience impl only used to use any Db on the fly as the db layer for revm’s CacheDB
This is useful to create blocks without actually writing to the Db, but rather in the cache of
the CacheDB see also
Backend::pending_block()