Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
ratankaliani committed Sep 5, 2024
1 parent 83ef772 commit b348555
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions utils/host/src/helpers.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use alloy_primitives::{hex, keccak256};
use kona_preimage::{HintWriterClient, PreimageKey, PreimageKeyType, PreimageOracleClient};

Check failure on line 2 in utils/host/src/helpers.rs

View workflow job for this annotation

GitHub Actions / Formatting & Clippy

unused imports: `HintWriterClient`, `PreimageOracleClient`
use op_succinct_client_utils::BytesHasherBuilder;
use std::{collections::HashMap, fs, io::Read, path::PathBuf};
use kona_preimage::{HintWriterClient, PreimageKey, PreimageKeyType, PreimageOracleClient};

pub fn load_kv_store(data_dir: &PathBuf) -> HashMap<[u8; 32], Vec<u8>, BytesHasherBuilder> {
let capacity = get_file_count(data_dir);
Expand All @@ -14,21 +14,23 @@ pub fn load_kv_store(data_dir: &PathBuf) -> HashMap<[u8; 32], Vec<u8>, BytesHash
if path.is_file() {
// Extract the file name
let file_name = path.file_stem().unwrap().to_str().unwrap();
println!("File name: {:?}", file_name);
// println!("File name: {:?}", file_name);

// Convert the file name to PreimageKey
if let Ok(key) = hex::decode(file_name) {

Check failure on line 20 in utils/host/src/helpers.rs

View workflow job for this annotation

GitHub Actions / Formatting & Clippy

unused variable: `key`
// Hash the key with SHA256.
let key = PreimageKey::new(keccak256(&key).into(), PreimageKeyType::Keccak256);

// Read the file contents
let mut file = fs::File::open(path).expect("Failed to open file");
let mut contents = Vec::new();
file.read_to_end(&mut contents).expect("Failed to read file");

// Insert the key-value pair into the cache
let key = PreimageKey::new(keccak256(&contents).into(), PreimageKeyType::Keccak256);

// Insert the key-value pair into the cache
println!("Inserting key: {:?}", key);
cache.insert(key.try_into().unwrap(), contents);
cache.insert(key.into(), contents);
}
}
}
Expand Down

0 comments on commit b348555

Please sign in to comment.