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