Optimize transaction creation #98

Merged
pitmutt merged 17 commits from rav001 into milestone2 2024-10-30 16:47:12 +00:00
Showing only changes of commit 2e9e6d8831 - Show all commits

View file

@ -1590,26 +1590,32 @@ pub extern "C" fn rust_wrapper_combine_orchard_nodes(
){ ){
let left_in: Vec<u8> = marshall_from_haskell_var(left, left_len, RW); let left_in: Vec<u8> = marshall_from_haskell_var(left, left_len, RW);
let right_in: Vec<u8> = marshall_from_haskell_var(right, right_len, RW); let right_in: Vec<u8> = marshall_from_haskell_var(right, right_len, RW);
let left_node = MerkleHashOrchard::from_bytes(&to_array(left_in)); if left_in.len() > 1 {
if left_node.is_some().into() { let n = MerkleHashOrchard::combine(Level::new(level), &MerkleHashOrchard::empty_leaf(), &MerkleHashOrchard::empty_leaf());
if right_in.len() > 1 {
let right_node = MerkleHashOrchard::from_bytes(&to_array(right_in));
if right_node.is_some().into() {
let n = MerkleHashOrchard::combine(Level::new(level), &left_node.unwrap(), &right_node.unwrap());
let h = Hhex { bytes: n.to_bytes().to_vec() };
marshall_to_haskell_var(&h, out, out_len, RW);
} else {
let h0 = Hhex { bytes: vec![0] };
marshall_to_haskell_var(&h0, out, out_len, RW);
}
} else {
let n = MerkleHashOrchard::combine(Level::new(level), &left_node.unwrap(), &MerkleHashOrchard::empty_leaf());
let h = Hhex { bytes: n.to_bytes().to_vec() }; let h = Hhex { bytes: n.to_bytes().to_vec() };
marshall_to_haskell_var(&h, out, out_len, RW); marshall_to_haskell_var(&h, out, out_len, RW);
}
} else { } else {
let h0 = Hhex { bytes: vec![0] }; let left_node = MerkleHashOrchard::from_bytes(&to_array(left_in));
marshall_to_haskell_var(&h0, out, out_len, RW); if left_node.is_some().into() {
if right_in.len() > 1 {
let right_node = MerkleHashOrchard::from_bytes(&to_array(right_in));
if right_node.is_some().into() {
let n = MerkleHashOrchard::combine(Level::new(level), &left_node.unwrap(), &right_node.unwrap());
let h = Hhex { bytes: n.to_bytes().to_vec() };
marshall_to_haskell_var(&h, out, out_len, RW);
} else {
let h0 = Hhex { bytes: vec![0] };
marshall_to_haskell_var(&h0, out, out_len, RW);
}
} else {
let n = MerkleHashOrchard::combine(Level::new(level), &left_node.unwrap(), &MerkleHashOrchard::empty_leaf());
let h = Hhex { bytes: n.to_bytes().to_vec() };
marshall_to_haskell_var(&h, out, out_len, RW);
}
} else {
let h0 = Hhex { bytes: vec![0] };
marshall_to_haskell_var(&h0, out, out_len, RW);
}
} }
} }