From 7a4954c242b8786873ab9304fc2e7b41f1dc7e39 Mon Sep 17 00:00:00 2001 From: Jack Grigg Date: Fri, 8 Sep 2023 03:44:03 +0000 Subject: [PATCH] zcash_client_sqlite: Fix off-by-one in `scan_complete` Shard end heights are end-inclusive, while Rust `Range`s are end-exclusive. Co-authored-by: Kris Nuttycombe --- zcash_client_sqlite/src/wallet/scanning.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/zcash_client_sqlite/src/wallet/scanning.rs b/zcash_client_sqlite/src/wallet/scanning.rs index 17868e00c..8aad71a40 100644 --- a/zcash_client_sqlite/src/wallet/scanning.rs +++ b/zcash_client_sqlite/src/wallet/scanning.rs @@ -674,8 +674,9 @@ pub(crate) fn scan_complete( let range_min = range_min.map(|h| wallet_birthday.map_or(h, |b| std::cmp::max(b, h))); - // get the block height for the end of the current shard - let range_max = sapling_shard_end(*max_idx)?; + // Get the block height for the end of the current shard, and make it an + // exclusive end bound. + let range_max = sapling_shard_end(*max_idx)?.map(|end| end + 1); Ok::, rusqlite::Error>(Range { start: range.start.min(range_min.unwrap_or(range.start)),