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 5139f9dd7b - Show all commits

View file

@ -1795,43 +1795,41 @@ pub extern "C" fn rust_wrapper_create_transaction(
build: bool, build: bool,
out: *mut u8, out: *mut u8,
out_len: &mut usize){ out_len: &mut usize){
//let sap_wit_in: Vec<u8> = marshall_from_haskell_var(sap_wit, sap_wit_len, RW);
//let sap_wit_reader = Cursor::new(sap_wit_in);
//let sap_iw = read_commitment_tree::<Node, Cursor<Vec<u8>>, SAPLING_DEPTH>(sap_wit_reader);
let sap_input: Vec<HsaplingInput> = marshall_from_haskell_var(s_input, s_input_len, RW); let sap_input: Vec<HsaplingInput> = marshall_from_haskell_var(s_input, s_input_len, RW);
let sap_anchor = let sap_anchor =
if sap_input.is_empty() { if sap_input.is_empty() {
None let sap_wit_in: Vec<u8> = marshall_from_haskell_var(sap_wit, sap_wit_len, RW);
let sap_wit_reader = Cursor::new(sap_wit_in);
let sap_iw = read_commitment_tree::<Node, Cursor<Vec<u8>>, SAPLING_DEPTH>(sap_wit_reader);
match sap_iw {
Ok(s_iw) => {
Some(SaplingAnchor::from(s_iw.root()))
},
Err(_e) => {
None
}
}
} else { } else {
let si = &sap_input[0]; let si = &sap_input[0];
let swit_reader = Cursor::new(&si.iw); let swit_reader = Cursor::new(&si.iw);
let iw: IncrementalWitness<Node, SAPLING_DEPTH> = read_incremental_witness(swit_reader).unwrap(); let iw: IncrementalWitness<Node, SAPLING_DEPTH> = read_incremental_witness(swit_reader).unwrap();
Some(SaplingAnchor::from(iw.root())) Some(SaplingAnchor::from(iw.root()))
}; };
//let sap_anchor = match sap_iw {
//Ok(s_iw) => {
//Some(SaplingAnchor::from(s_iw.root()))
//},
//Err(_e) => {
//None
//}
//};
//println!("{:?}", sap_anchor); //println!("{:?}", sap_anchor);
//let orch_wit_in: Vec<u8> = marshall_from_haskell_var(orch_wit, orch_wit_len, RW);
//let orch_wit_reader = Cursor::new(orch_wit_in);
//let orch_iw = read_commitment_tree::<MerkleHashOrchard, Cursor<Vec<u8>>, 32>(orch_wit_reader);
let orch_input: Vec<HorchardInput> = marshall_from_haskell_var(o_input, o_input_len, RW); let orch_input: Vec<HorchardInput> = marshall_from_haskell_var(o_input, o_input_len, RW);
//let orch_anchor = match orch_iw {
//Ok(o_iw) => {
//Some(OrchardAnchor::from(o_iw.root()))
//},
//Err(_e) => {
//None
//}
//};
let orch_anchor = let orch_anchor =
if orch_input.is_empty() { if orch_input.is_empty() {
None let orch_wit_in: Vec<u8> = marshall_from_haskell_var(orch_wit, orch_wit_len, RW);
let orch_wit_reader = Cursor::new(orch_wit_in);
let orch_iw = read_commitment_tree::<MerkleHashOrchard, Cursor<Vec<u8>>, 32>(orch_wit_reader);
match orch_iw {
Ok(o_iw) => {
Some(OrchardAnchor::from(o_iw.root()))
},
Err(_e) => {
None
}
}
} else { } else {
let oi = &orch_input[0]; let oi = &orch_input[0];
let wit_reader = Cursor::new(&oi.iw); let wit_reader = Cursor::new(&oi.iw);