Skip to content

Commit

Permalink
fix(rpc): FilterIter returns None if spks is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
ValuedMammal committed Sep 23, 2024
1 parent 881bf3d commit 7d34480
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions crates/bitcoind_rpc/src/bip158.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,18 @@ impl<'c, C: RpcApi> Iterator for FilterIter<'c, C> {
type Item = Result<Event, Error>;

fn next(&mut self) -> Option<Self::Item> {
if self.spks.is_empty() {
return None;
}

let (block, filter) = self.next_filter.clone()?;

(|| -> Result<_, Error> {
// if the next filter matches any of our watched spks, get the block
// and return it, inserting relevant block ids along the way
let height = block.height;
let hash = block.hash;
let event = if self.spks.is_empty() {
Event::NoMatch(height)
} else if filter
let event = if filter
.match_any(&hash, self.spks.iter().map(|script| script.as_bytes()))
.map_err(Error::Bip158)?
{
Expand Down

0 comments on commit 7d34480

Please sign in to comment.