Skip to content

Commit

Permalink
Apply nits
Browse files Browse the repository at this point in the history
  • Loading branch information
i1i1 committed Dec 25, 2024
1 parent 38ffa48 commit eedf61a
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions bins/fetch/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
serde_json::to_writer(block_file, &block)
.map_err(|err| format!("Failed to write block to file: {err}"))?;

// Populate bytecodes and state from RPC storage.
// TODO: Deduplicate logic with [for_each_block_from_disk] when there is more usage
let mut bytecodes: BTreeMap<B256, EvmCode> = match File::open("data/bytecodes.bincode.gz") {
Ok(compressed_file) => {
Expand All @@ -82,7 +83,6 @@ async fn main() -> Result<(), Box<dyn Error>> {
};
bytecodes.extend(storage.get_cache_bytecodes());

// Populate bytecodes and state from RPC storage.
let mut state = BTreeMap::<Address, EvmAccount>::new();
for (address, mut account) in storage.get_cache_accounts() {
if let Some(code) = account.code.take() {
Expand Down Expand Up @@ -110,11 +110,10 @@ async fn main() -> Result<(), Box<dyn Error>> {

// TODO: Deduplicate logic with [for_each_block_from_disk] when there is more usage
let mut block_hashes = match File::open("data/block_hashes.bincode") {
Ok(compressed_file) => bincode::deserialize_from(compressed_file)
.map_err(|err| format!("Failed to deserialize bytecodes from file: {err}"))?,
Err(_) => BTreeMap::<u64, B256>::new(),
Ok(compressed_file) => bincode::deserialize_from::<_, BTreeMap<u64, B256>>(compressed_file)
.map_err(|err| format!("Failed to deserialize block hashes from file: {err}"))?,
Err(_) => BTreeMap::new(),
};

block_hashes.extend(storage.get_cache_block_hashes());

if !block_hashes.is_empty() {
Expand Down

0 comments on commit eedf61a

Please sign in to comment.