Clarify TxGraph::try_filter_chain_unspents logic

This commit is contained in:
志宇 2023-05-11 11:59:57 +08:00
parent 96b1075132
commit fb75aa94a9
No known key found for this signature in database
GPG Key ID: F6345C9837C2BDE8

View File

@ -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