Skip to content

Commit

Permalink
Handle bitcoin_slices::Error::VisitBreak when looking up transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
romanz committed Aug 4, 2023
1 parent 50e0d3a commit e39ae67
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use anyhow::{Context, Result};
use bitcoin::{BlockHash, Transaction, Txid};
use bitcoin_slices::{
bsl::{self, FindTransaction},
Error::VisitBreak,
Visit,
};

Expand Down Expand Up @@ -107,7 +108,10 @@ impl Tracker {
let mut result = None;
daemon.for_blocks(blockhashes, |blockhash, block| {
let mut visitor = FindTransaction::new(txid);
bsl::Block::visit(&block, &mut visitor).unwrap();
match bsl::Block::visit(&block, &mut visitor) {
Ok(_) | Err(VisitBreak) => (),
Err(e) => panic!("core returned invalid block: {:?}", e),
}
if let Some(tx) = visitor.tx_found() {
result = Some((blockhash, tx));
}
Expand Down

0 comments on commit e39ae67

Please sign in to comment.