Skip to content
Prev Previous commit
Next Next commit
chore: tie journal database with database getter
  • Loading branch information
rakita committed Dec 17, 2024
commit d146253a1c4d26f6530cb92f57d76d7842d43c2c
24 changes: 19 additions & 5 deletions crates/context/interface/src/journaled_state.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
use auto_impl::auto_impl;
use core::ops::{Deref, DerefMut};
use database_interface::Database;
use database_interface::{Database, DatabaseGetter};
use primitives::{Address, B256, U256};
use specification::hardfork::SpecId;
use state::{Account, Bytecode};
Expand Down Expand Up @@ -240,9 +239,24 @@ impl<T> Eip7702CodeLoad<T> {
pub type JournalStateGetterDBError<CTX> =
<<<CTX as JournalStateGetter>::Journal as JournaledState>::Database as Database>::Error;

#[auto_impl(&mut, Box)]
pub trait JournalStateGetter {
type Journal: JournaledState;
pub trait JournalStateGetter: DatabaseGetter {
type Journal: JournaledState<Database = <Self as DatabaseGetter>::Database>;

fn journal(&mut self) -> &mut Self::Journal;
}

impl<T: JournalStateGetter> JournalStateGetter for &mut T {
type Journal = T::Journal;

fn journal(&mut self) -> &mut Self::Journal {
T::journal(*self)
}
}

impl<T: JournalStateGetter> JournalStateGetter for Box<T> {
type Journal = T::Journal;

fn journal(&mut self) -> &mut Self::Journal {
T::journal(self.as_mut())
}
}
1 change: 1 addition & 0 deletions crates/context/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ impl<BLOCK: Block + Default, TX: Transaction + Default, DB: Database, CHAIN: Def
}
}
}

impl<BLOCK, TX, CFG, DB, CHAIN> Context<BLOCK, TX, CFG, DB, CHAIN>
where
BLOCK: Block,
Expand Down