DatabaseCommit

Trait DatabaseCommit 

pub trait DatabaseCommit {
    // Required method
    fn commit(&mut self, changes: HashMap<Address, Account, DefaultHashBuilder>);

    // Provided method
    fn commit_iter(
        &mut self,
        changes: &mut dyn Iterator<Item = (Address, Account)>,
    ) { ... }
}
Expand description

EVM database commit interface.

§Dyn Compatibility

This trait is dyn-compatible. The commit_iter method uses &mut dyn Iterator which allows it to be called on trait objects while remaining in the vtable.

Required Methods§

fn commit(&mut self, changes: HashMap<Address, Account, DefaultHashBuilder>)

Commit changes to the database.

Provided Methods§

fn commit_iter(&mut self, changes: &mut dyn Iterator<Item = (Address, Account)>)

Commit changes to the database with an iterator.

Implementors of DatabaseCommit should override this method when possible for efficiency.

Callers should prefer using DatabaseCommit::commit when they already have a HashMap.

§Dyn Compatibility

This method uses &mut dyn Iterator to remain object-safe and callable on trait objects. For ergonomic usage with impl IntoIterator, use the inherent method commit_from_iter on dyn DatabaseCommit.

Implementations§

§

impl dyn DatabaseCommit

Inherent implementation for dyn DatabaseCommit trait objects.

This provides commit_from_iter as an ergonomic wrapper around the trait’s commit_iter method, accepting impl IntoIterator for convenience.

pub fn commit_from_iter( &mut self, changes: impl IntoIterator<Item = (Address, Account)>, )

Commit changes to the database with an iterator.

This is an ergonomic wrapper that accepts impl IntoIterator and delegates to the trait’s commit_iter method.

Implementations on Foreign Types§

§

impl DatabaseCommit for MemDb

§

impl<'a, T> DatabaseCommit for &'a mut T
where T: 'a + DatabaseCommit + ?Sized,

§

fn commit(&mut self, changes: HashMap<Address, Account, DefaultHashBuilder>)

§

fn commit_iter(&mut self, changes: &mut dyn Iterator<Item = (Address, Account)>)

§

impl<T> DatabaseCommit for Box<T>
where T: DatabaseCommit + ?Sized,

§

fn commit(&mut self, changes: HashMap<Address, Account, DefaultHashBuilder>)

§

fn commit_iter(&mut self, changes: &mut dyn Iterator<Item = (Address, Account)>)

Implementors§

§

impl DatabaseCommit for Backend

§

impl DatabaseCommit for CowBackend<'_>

§

impl DatabaseCommit for forge::core::backend::MemDb

§

impl DatabaseCommit for ForkedDatabase

§

impl<DB> DatabaseCommit for BalDatabase<DB>
where DB: DatabaseCommit,

§

impl<DB> DatabaseCommit for State<DB>
where DB: Database,

§

impl<ExtDB> DatabaseCommit for CacheDB<ExtDB>

§

impl<L, R> DatabaseCommit for Either<L, R>

§

impl<T> DatabaseCommit for WrapDatabaseRef<T>