Skip to content

Commit

Permalink
Return first txid-matching transaction (#933)
Browse files Browse the repository at this point in the history
  • Loading branch information
romanz authored Sep 1, 2023
1 parent 6f82108 commit 3c6028e
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down

0 comments on commit 3c6028e

Please sign in to comment.