Skip to content

Commit

Permalink
zcash_client_sqlite: Address comments from code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
nuttycom committed Jun 22, 2024
1 parent 72d8df8 commit 10258b8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
10 changes: 6 additions & 4 deletions zcash_client_sqlite/src/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1856,8 +1856,10 @@ pub(crate) fn truncate_to_height<P: consensus::Parameters>(
// spends in the transaction.
conn.execute(
"UPDATE transparent_received_outputs
SET max_observed_unspent_height = NULL
WHERE max_observed_unspent_height > :height",
SET max_observed_unspent_height = CASE WHEN tx.mined_height <= :height THEN :height ELSE NULL END
FROM transactions tx
WHERE tx.id_tx = transaction_id
AND max_observed_unspent_height > :height",
named_params![":height": u32::from(block_height)],
)?;

Expand All @@ -1866,8 +1868,8 @@ pub(crate) fn truncate_to_height<P: consensus::Parameters>(
conn.execute(
"UPDATE transactions
SET block = NULL, mined_height = NULL, tx_index = NULL
WHERE block > ?",
[u32::from(block_height)],
WHERE mined_height > :height",
named_params![":height": u32::from(block_height)],
)?;

// If we're removing scanned blocks, we need to truncate the note commitment tree and remove
Expand Down
9 changes: 6 additions & 3 deletions zcash_client_sqlite/src/wallet/db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,8 @@ CREATE INDEX orchard_received_notes_tx ON orchard_received_notes (

/// A junction table between received Orchard notes and the transactions that spend them.
///
/// This is identical to [`TABLE_SAPLING_RECEIVED_NOTE_SPENDS`]; see its documentation for
/// details.
/// Thie plays the same role for Orchard notes as does [`TABLE_SAPLING_RECEIVED_NOTE_SPENDS`] for
/// Sapling notes; see its documentation for details.
pub(super) const TABLE_ORCHARD_RECEIVED_NOTE_SPENDS: &str = "
CREATE TABLE orchard_received_note_spends (
orchard_received_note_id INTEGER NOT NULL,
Expand Down Expand Up @@ -245,7 +245,10 @@ CREATE TABLE orchard_received_note_spends (
/// - `transaction_id`: Reference to the transaction in which this TXO was created
/// - `output_index`: The output index of this TXO in the transaction referred to by `transaction_id`
/// - `account_id`: The account that controls spend authority for this TXO
/// - `address`: The address to which this TXO was sent
/// - `address`: The address to which this TXO was sent. We store this address to make querying
/// for UTXOs for a single address easier, because when shielding we always select UTXOs
/// for only a single address at a time to prevent linking addresses in the shielding
/// transaction.
/// - `script`: The full txout script
/// - `value_zat`: The value of the TXO in zatoshis
/// - `max_observed_unspent_height`: The maximum block height at which this TXO was either
Expand Down

0 comments on commit 10258b8

Please sign in to comment.