Skip to content

Commit

Permalink
simplify db
Browse files Browse the repository at this point in the history
  • Loading branch information
tcoratger committed Jul 25, 2024
1 parent 7427bbd commit 5782c63
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions crates/exex/src/db.rs
Original file line number Diff line number Diff line change
@@ -1,23 +1,16 @@
use reth_primitives::{
revm_primitives::{AccountInfo, Bytecode},
Address, Bytes, SealedBlockWithSenders, StorageEntry, B256, U256,
Address, SealedBlockWithSenders, B256, U256,
};
use reth_provider::OriginalValuesKnown;
use reth_revm::db::BundleState;
use rusqlite::Connection;
use std::{
collections::HashMap,
ops::{Deref, DerefMut},
str::FromStr,
sync::{Arc, Mutex, MutexGuard},
};

/// Types used inside RevertsInit to initialize revms reverts.
pub type AccountRevertInit = (Option<Option<AccountInfo>>, Vec<StorageEntry>);

/// Type used to initialize revms reverts.
pub type RevertsInit = HashMap<Address, AccountRevertInit>;

/// A struct representing the database, encapsulating a connection to the SQLite database.
///
/// The connection is protected by a `Mutex` for thread-safe access and is shared across
Expand Down Expand Up @@ -174,17 +167,8 @@ impl reth_revm::Database for Database {
self.get_account(address)
}

fn code_by_hash(&mut self, code_hash: B256) -> Result<Bytecode, Self::Error> {
let bytecode = self.connection().query_row::<String, _, _>(
"SELECT data FROM bytecode WHERE hash = ?",
(code_hash.to_string(),),
|row| row.get(0),
);
match bytecode {
Ok(data) => Ok(Bytecode::new_raw(Bytes::from_str(&data).unwrap())),
Err(rusqlite::Error::QueryReturnedNoRows) => Ok(Bytecode::default()),
Err(err) => Err(err.into()),
}
fn code_by_hash(&mut self, _code_hash: B256) -> Result<Bytecode, Self::Error> {
Ok(Default::default())
}

fn storage(&mut self, _address: Address, _index: U256) -> Result<U256, Self::Error> {
Expand Down

0 comments on commit 5782c63

Please sign in to comment.