From 30dd633de62536881cfe302546646481cb515090 Mon Sep 17 00:00:00 2001 From: Kris Nuttycombe Date: Thu, 10 Mar 2022 21:43:35 -0700 Subject: [PATCH] Apply suggestions from code review Co-authored-by: str4d --- src/rust/include/rust/orchard/wallet.h | 2 +- src/rust/src/wallet.rs | 9 ++++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/rust/include/rust/orchard/wallet.h b/src/rust/include/rust/orchard/wallet.h index ea75f603a..f3b3ff62e 100644 --- a/src/rust/include/rust/orchard/wallet.h +++ b/src/rust/include/rust/orchard/wallet.h @@ -100,7 +100,7 @@ typedef void (*push_spend_action_idx_callback_t)(void* rec, uint32_t actionIdx); * Searches the provided bundle for notes that are visible to the specified wallet's * incoming viewing keys, and adds those notes to the wallet. For each note decryptable * by one of the wallet's keys, this method will insert a `RawOrchardActionIVK` value into - * the provided `decryptedActionIVKs` referent using the `push_cb` callback. Note that + * the provided `callbackReceiver` referent using the `push_cb` callback. Note that * this callback can perform transformations on the provided RawOrchardActionIVK in this * process. For each action spending one of the wallet's notes, this method will insert * a `uint32_t` action index into the `spendingActionIdxs` referent. diff --git a/src/rust/src/wallet.rs b/src/rust/src/wallet.rs index f9fda369c..196c26012 100644 --- a/src/rust/src/wallet.rs +++ b/src/rust/src/wallet.rs @@ -372,9 +372,9 @@ impl Wallet { /// Restore note and potential spend data from a bundle using the provided /// metadata. /// - /// - `tx_height`: if the transaction containing the bundle has been mined, + /// - `tx_height`: if the transaction containing the bundle has been mined, /// this should contain the block height it was mined at - /// - `txid`: The ID for the transaction from which the provided bundle was + /// - `txid`: The ID for the transaction from which the provided bundle was /// extracted. /// - `bundle`: the bundle to decrypt notes from /// - `hints`: a map from action index to the incoming viewing key that decrypts @@ -773,18 +773,17 @@ pub extern "C" fn orchard_wallet_add_notes_from_bundle( let txid = TxId::from_bytes(*unsafe { txid.as_ref() }.expect("txid may not be null.")); if let Some(bundle) = unsafe { bundle.as_ref() } { let added = wallet.add_notes_from_bundle(&txid, bundle); - let mut involved = false; + let involved = + !(added.receive_action_metadata.is_empty() && added.spend_action_metadata.is_empty()); for (action_idx, ivk) in added.receive_action_metadata.into_iter() { let action_ivk = FFIActionIvk { action_idx: action_idx.try_into().unwrap(), ivk_ptr: Box::into_raw(Box::new(ivk.clone())), }; unsafe { (action_ivk_push_cb.unwrap())(cb_receiver, action_ivk) }; - involved = true; } for action_idx in added.spend_action_metadata { unsafe { (spend_idx_push_cb.unwrap())(cb_receiver, action_idx.try_into().unwrap()) }; - involved = true; } involved } else {