summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2025-06-25 08:18:23 +0000
committerSanto Cariotti <santo@dcariotti.me>2025-06-25 08:18:23 +0000
commit7bdb59e386b93c37cdc2c2b88fc2945ab0e64d57 (patch)
tree0b8224e6294df174fdec18f44459c8a33a2a0404 /examples
parent7c1afe0571293554e9c486a0e97aa9215ad64ee5 (diff)
Increase tree's speed avoiding to store data in a vec
Diffstat (limited to 'examples')
-rw-r--r--examples/proofer_blake3.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/examples/proofer_blake3.rs b/examples/proofer_blake3.rs
index 154b51c..62d1429 100644
--- a/examples/proofer_blake3.rs
+++ b/examples/proofer_blake3.rs
@@ -24,10 +24,7 @@ fn main() {
let mut nodes: Vec<Node> = Vec::new();
for filename in &filenames {
match std::fs::read(filename) {
- Ok(contents) => {
- let hash = Blake3Hasher::new().hash(&contents);
- nodes.push(Node::new_leaf(&contents, hash));
- }
+ Ok(contents) => nodes.push(Node::new_leaf(Blake3Hasher::new().hash(&contents))),
Err(e) => {
eprintln!("Failed to read file '{}': {}", filename, e);
std::process::exit(1);
@@ -35,13 +32,17 @@ fn main() {
}
}
- let first_node = nodes[0].clone();
let hasher = Blake3Hasher::new();
let proofer = DefaultProofer::new(&hasher, nodes);
let proof = proofer.generate(0).expect("Couldn't generate proof");
println!(
"{}",
- proofer.verify(&proof, first_node.data(), &root_hash[..], &hasher)
+ proofer.verify(
+ &proof,
+ std::fs::read(&filenames[0]).unwrap(),
+ &root_hash[..],
+ &hasher
+ )
);
}