use tempfile

This commit is contained in:
Giacomo Pasini 2025-04-24 13:22:35 +02:00
parent f980bb4162
commit 9287a16b09
No known key found for this signature in database
GPG Key ID: FC08489D2D895D4B
2 changed files with 7 additions and 4 deletions

View File

@ -18,3 +18,4 @@ url = { version = "2" }
hex = { version = "0.4" }
futures = { version = "0.3" }
kzgrs-backend = { git = "https://github.com/logos-co/nomos", branch = "master" }
tempfile = "3.19.1"

View File

@ -1,5 +1,6 @@
use tokio::process::Command;
use std::path::Path;
use std::io::Write;
use reqwest::Url;
use tracing::{error, info};
@ -25,9 +26,10 @@ pub async fn verify_proof(
.bytes()
.await
.map_err(|e| format!("Failed to read proof response: {}", e))?;
let filename = format!("{}-{}.zkp", block_number, block_count + block_number);
tokio::fs::write(&filename, &proof)
.await
let mut tempfile = tempfile::NamedTempFile::new()
.map_err(|e| format!("Failed to create temporary file: {}", e))?;
tempfile.write_all(&proof)
.map_err(|e| format!("Failed to write proof to file: {}", e))?;
@ -37,7 +39,7 @@ pub async fn verify_proof(
&format!("--rpc={}", rpc),
&format!("--block-number={}", block_number),
&format!("--block-count={}", block_count),
&format!("--file={}", filename),
&format!("--file={}", tempfile.path().display()),
])
.output().await
.map_err(|e| format!("Failed to execute zeth-ethereum verify: {}", e))?;