Skip to content

Commit 97e5e9f

Browse files
nuttycomstr4d
andauthored
Apply suggestions from code review
Co-authored-by: str4d <[email protected]>
1 parent 7645baa commit 97e5e9f

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

zcash_client_sqlite/src/wallet/common.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ fn per_protocol_names(protocol: ShieldedProtocol) -> (&'static str, &'static str
3131
fn unscanned_tip_exists(
3232
conn: &Connection,
3333
anchor_height: BlockHeight,
34-
table_prefix: &str,
34+
table_prefix: &'static str,
3535
) -> Result<bool, rusqlite::Error> {
3636
// v_sapling_shard_unscanned_ranges only returns ranges ending on or after wallet birthday, so
3737
// we don't need to refer to the birthday in this query.
@@ -140,8 +140,6 @@ where
140140
// 3) Select all notes for which the running sum was less than the required value, as
141141
// well as a single note for which the sum was greater than or equal to the
142142
// required value, bringing the sum of all selected notes across the threshold.
143-
//
144-
// 4) Match the selected notes against the witnesses at the desired height.
145143
let mut stmt_select_notes = conn.prepare_cached(
146144
&format!(
147145
"WITH eligible AS (

zcash_client_sqlite/src/wallet/orchard.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ fn to_spendable_note<P: consensus::Parameters>(
140140
let ufvk_str: Option<String> = row.get(8)?;
141141
let scope_code: Option<i64> = row.get(9)?;
142142

143+
// If we don't have information about the recipient key scope or the ufvk we can't determine
144+
// which spending key to use. This may be because the received note was associated with an
145+
// imported viewing key, so we treat such notes as not spendable. Although this method is
146+
// presently only called using the results of queries where both the ufvk and
147+
// recipient_key_scope columns are checked to be non-null, this is method is written
148+
// defensively to account for the fact that both of these are nullable columns in case it
149+
// is used elsewhere in the future.
143150
ufvk_str
144151
.zip(scope_code)
145152
.map(|(ufvk_str, scope_code)| {
@@ -176,10 +183,6 @@ fn to_spendable_note<P: consensus::Parameters>(
176183
.transpose()
177184
}
178185

179-
// The `clippy::let_and_return` lint is explicitly allowed here because a bug in Clippy
180-
// (https://github.com/rust-lang/rust-clippy/issues/11308) means it fails to identify that the `result` temporary
181-
// is required in order to resolve the borrows involved in the `query_and_then` call.
182-
#[allow(clippy::let_and_return)]
183186
pub(crate) fn get_spendable_orchard_note<P: consensus::Parameters>(
184187
conn: &Connection,
185188
params: &P,

0 commit comments

Comments
 (0)