Skip to content

Commit

Permalink
Clarify TxGraph::try_filter_chain_unspents logic
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlinjin committed May 11, 2023
1 parent 96b1075 commit fb75aa9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion crates/chain/src/tx_graph.rs
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,12 @@ impl<A: Anchor> TxGraph<A> {
outpoints: impl IntoIterator<Item = (S, OutPoint)> + 'a,
) -> impl Iterator<Item = Result<(S, FullTxOut<ObservedAs<A>>), C::Error>> + 'a {
self.try_filter_chain_txouts(chain, chain_tip, outpoints)
.filter(|r| !matches!(r, Ok((_, full_txo)) if full_txo.spent_by.is_some()))
.filter(|r| match r {
// keep unspents, drop spents
Ok((_, full_txo)) => full_txo.spent_by.is_none(),
// keep errors
Err(_) => true,
})
}

/// Get a filtered list of unspent outputs (UTXOs) from the given `outpoints` that are in
Expand Down

0 comments on commit fb75aa9

Please sign in to comment.