feat(tx_graph): Add method txs_with_no_anchor_or_last_seen

This commit is contained in:
valued mammal
2024-06-25 12:46:53 -04:00
parent 496601b8b1
commit 6204d2c766
3 changed files with 25 additions and 1 deletions

View File

@@ -258,6 +258,19 @@ impl<A> TxGraph<A> {
})
}
/// Iterate over graph transactions with no anchors or last-seen.
pub fn txs_with_no_anchor_or_last_seen(
&self,
) -> impl Iterator<Item = TxNode<'_, Arc<Transaction>, A>> {
self.full_txs().filter_map(|tx| {
if tx.anchors.is_empty() && tx.last_seen_unconfirmed.is_none() {
Some(tx)
} else {
None
}
})
}
/// Get a transaction by txid. This only returns `Some` for full transactions.
///
/// Refer to [`get_txout`] for getting a specific [`TxOut`].