zcash-sync/src/print.rs

29 lines
767 B
Rust

use zcash_primitives::sapling::Node;
use zcash_primitives::merkle_tree::{CommitmentTree, IncrementalWitness};
#[allow(dead_code)]
pub fn print_node(n: &Node) {
println!("{:?}", hex::encode(n.repr));
}
#[allow(dead_code)]
pub fn print_tree(t: &CommitmentTree<Node>) {
println!("{:?}", t.left.map(|n| hex::encode(n.repr)));
println!("{:?}", t.right.map(|n| hex::encode(n.repr)));
for p in t.parents.iter() {
println!("{:?}", p.map(|n| hex::encode(n.repr)));
}
}
#[allow(dead_code)]
pub fn print_witness(w: &IncrementalWitness<Node>) {
println!("Tree");
print_tree(&w.tree);
println!("Filled");
for n in w.filled.iter() {
print_node(n);
}
println!("Cursor");
w.cursor.as_ref().map(|c| print_tree(c));
}