From 18a31e332dae86c755b292781de941229de86502 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Sat, 2 Dec 2023 11:29:42 +0200 Subject: [PATCH] handle false-positive txid index hit --- src/tracker.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/tracker.rs b/src/tracker.rs index a6c50524d..0f0959261 100644 --- a/src/tracker.rs +++ b/src/tracker.rs @@ -105,7 +105,7 @@ impl Tracker { ) -> Result> { // Note: there are two blocks with coinbase transactions having same txid (see BIP-30) let blockhashes = self.index.filter_by_txid(txid); - let result = daemon + Ok(daemon .for_blocks(blockhashes, |blockhash, block| { let mut visitor = FindTransaction::new(txid); match bsl::Block::visit(&block, &mut visitor) { @@ -114,9 +114,8 @@ impl Tracker { } visitor.tx_found().map(|tx| (blockhash, tx)) })? - .first() - .cloned() - .flatten(); - Ok(result) + .into_iter() + .filter_map(|e| e) // skip non-matching blocks, in case of a false-positive index hit + .next()) // return first match } }