Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: str4d <[email protected]>
  • Loading branch information
nuttycom and str4d authored Mar 12, 2024
1 parent 7645baa commit 97e5e9f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
4 changes: 1 addition & 3 deletions zcash_client_sqlite/src/wallet/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fn per_protocol_names(protocol: ShieldedProtocol) -> (&'static str, &'static str
fn unscanned_tip_exists(
conn: &Connection,
anchor_height: BlockHeight,
table_prefix: &str,
table_prefix: &'static str,
) -> Result<bool, rusqlite::Error> {
// v_sapling_shard_unscanned_ranges only returns ranges ending on or after wallet birthday, so
// we don't need to refer to the birthday in this query.
Expand Down Expand Up @@ -140,8 +140,6 @@ where
// 3) Select all notes for which the running sum was less than the required value, as
// well as a single note for which the sum was greater than or equal to the
// required value, bringing the sum of all selected notes across the threshold.
//
// 4) Match the selected notes against the witnesses at the desired height.
let mut stmt_select_notes = conn.prepare_cached(
&format!(
"WITH eligible AS (
Expand Down
11 changes: 7 additions & 4 deletions zcash_client_sqlite/src/wallet/orchard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,13 @@ fn to_spendable_note<P: consensus::Parameters>(
let ufvk_str: Option<String> = row.get(8)?;
let scope_code: Option<i64> = row.get(9)?;

Check warning on line 141 in zcash_client_sqlite/src/wallet/orchard.rs

View check run for this annotation

Codecov / codecov/patch

zcash_client_sqlite/src/wallet/orchard.rs#L140-L141

Added lines #L140 - L141 were not covered by tests

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

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

0 comments on commit 97e5e9f

Please sign in to comment.