Functions to create and manage Orchard commitment trees #99
1 changed files with 7 additions and 1 deletions
|
@ -1514,7 +1514,13 @@ pub extern "C" fn rust_wrapper_read_orchard_frontier(
|
||||||
Some(f2) => {
|
Some(f2) => {
|
||||||
let (pos, leaf, omm) = f2.clone().into_parts();
|
let (pos, leaf, omm) = f2.clone().into_parts();
|
||||||
let f = Hfrontier { position: <u64>::from(pos), leaf: Hhex { bytes: leaf.to_bytes().to_vec()}, ommers: omm.iter().map(|&x| Hhex { bytes: x.to_bytes().to_vec()}).collect()};
|
let f = Hfrontier { position: <u64>::from(pos), leaf: Hhex { bytes: leaf.to_bytes().to_vec()}, ommers: omm.iter().map(|&x| Hhex { bytes: x.to_bytes().to_vec()}).collect()};
|
||||||
|
let comm_tree2: Frontier<MerkleHashOrchard,32> = Frontier::from_parts(Position::from(f.position), MerkleHashOrchard::from_bytes(&to_array(f.leaf.bytes.clone())).unwrap(), f.ommers.iter().map(|x| MerkleHashOrchard::from_bytes(&to_array(x.bytes.clone())).unwrap() ).collect()).unwrap();
|
||||||
|
if f1.root() == comm_tree2.root() {
|
||||||
marshall_to_haskell_var(&f, out, out_len, RW);
|
marshall_to_haskell_var(&f, out, out_len, RW);
|
||||||
|
} else {
|
||||||
|
let f0 = Hfrontier { position: 0, leaf: Hhex { bytes: vec![0]}, ommers: vec![Hhex { bytes: vec![0]}]};
|
||||||
|
marshall_to_haskell_var(&f0, out, out_len, RW);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
None => {
|
None => {
|
||||||
let f0 = Hfrontier { position: 0, leaf: Hhex { bytes: vec![0]}, ommers: vec![Hhex { bytes: vec![0]}]};
|
let f0 = Hfrontier { position: 0, leaf: Hhex { bytes: vec![0]}, ommers: vec![Hhex { bytes: vec![0]}]};
|
||||||
|
|
Loading…
Reference in a new issue