diff --git a/host/src/lib.rs b/host/src/lib.rs index c5c2cf16..1c2fed3a 100644 --- a/host/src/lib.rs +++ b/host/src/lib.rs @@ -51,8 +51,9 @@ pub fn save_receipt(receipt_label: &String, receipt_data: & } fn zkp_cache_path(receipt_label: &String) -> String { - Path::new("cache_zkp") - .join(format!("{}.zkp", receipt_label)) + let dir = Path::new("cache_zkp"); + std::fs::create_dir_all(&dir).expect("Could not create directory"); + dir.join(format!("{}.zkp", receipt_label)) .to_str() .unwrap() .to_string() diff --git a/lib/src/host/mod.rs b/lib/src/host/mod.rs index cb01bdeb..5feaad8b 100644 --- a/lib/src/host/mod.rs +++ b/lib/src/host/mod.rs @@ -24,10 +24,9 @@ pub mod rpc_db; pub mod verify; pub fn cache_file_path(cache_path: &Path, network: &str, block_no: u64, ext: &str) -> PathBuf { - cache_path - .join(network) - .join(block_no.to_string()) - .with_extension(ext) + let dir = cache_path.join(network); + std::fs::create_dir_all(&dir).expect("Could not create directory"); + dir.join(block_no.to_string()).with_extension(ext) } #[derive(Clone)] diff --git a/lib/src/host/rpc_db.rs b/lib/src/host/rpc_db.rs index 2a4cba0b..7b1c4662 100644 --- a/lib/src/host/rpc_db.rs +++ b/lib/src/host/rpc_db.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use std::path::{Path, PathBuf}; +use std::path::PathBuf; use anyhow::Context; use zeth_primitives::{ @@ -22,7 +22,10 @@ use zeth_primitives::{ }; use crate::{ - host::provider::{new_provider, BlockQuery}, + host::{ + cache_file_path, + provider::{new_provider, BlockQuery}, + }, optimism::{ batcher_db::{BatcherDb, BlockInput, MemDb}, config::ChainConfig, @@ -30,13 +33,6 @@ use crate::{ }, }; -fn cache_file_path(cache_path: &Path, network: &str, block_no: u64, ext: &str) -> PathBuf { - cache_path - .join(network) - .join(block_no.to_string()) - .with_extension(ext) -} - fn eth_cache_path(cache: &Option, block_no: u64) -> Option { cache .as_ref()