1use alloy_primitives::{Address, B256, U256};
2use revm::{
3 bytecode::Bytecode,
4 state::{AccountInfo, FlaggedStorage},
5 Database,
6};
7
8#[derive(Debug, Clone)]
12pub enum Either<L, R> {
13 Left(L),
15 Right(R),
17}
18
19impl<L, R> Database for Either<L, R>
20where
21 L: Database,
22 R: Database<Error = L::Error>,
23{
24 type Error = L::Error;
25
26 fn basic(&mut self, address: Address) -> Result<Option<AccountInfo>, Self::Error> {
27 match self {
28 Self::Left(db) => db.basic(address),
29 Self::Right(db) => db.basic(address),
30 }
31 }
32
33 fn code_by_hash(&mut self, code_hash: B256) -> Result<Bytecode, Self::Error> {
34 match self {
35 Self::Left(db) => db.code_by_hash(code_hash),
36 Self::Right(db) => db.code_by_hash(code_hash),
37 }
38 }
39
40 fn storage(&mut self, address: Address, index: U256) -> Result<FlaggedStorage, Self::Error> {
41 match self {
42 Self::Left(db) => db.storage(address, index),
43 Self::Right(db) => db.storage(address, index),
44 }
45 }
46
47 fn block_hash(&mut self, number: u64) -> Result<B256, Self::Error> {
48 match self {
49 Self::Left(db) => db.block_hash(number),
50 Self::Right(db) => db.block_hash(number),
51 }
52 }
53}