From 3c6028ed4d433800c54328902b2286b7d5016355 Mon Sep 17 00:00:00 2001 From: Roman Zeyde Date: Fri, 1 Sep 2023 16:27:42 +0300 Subject: [PATCH] Return first txid-matching transaction (#933) --- src/tracker.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/tracker.rs b/src/tracker.rs index ea32cf88c..39ba779ea 100644 --- a/src/tracker.rs +++ b/src/tracker.rs @@ -107,14 +107,14 @@ impl Tracker { let blockhashes = self.index.filter_by_txid(txid); let mut result = None; daemon.for_blocks(blockhashes, |blockhash, block| { + if result.is_some() { + return; // keep first matching transaction + } let mut visitor = FindTransaction::new(txid); - match bsl::Block::visit(&block, &mut visitor) { - Ok(_) | Err(VisitBreak) => (), + result = match bsl::Block::visit(&block, &mut visitor) { + Ok(_) | Err(VisitBreak) => visitor.tx_found().map(|tx| (blockhash, tx)), Err(e) => panic!("core returned invalid block: {:?}", e), - } - if let Some(tx) = visitor.tx_found() { - result = Some((blockhash, tx)); - } + }; })?; Ok(result) }