Skip to content

Commit

Permalink
docs(wallet): Explain .take usage
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlinjin committed Dec 10, 2024
1 parent 1196405 commit caa0f13
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/wallet/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1844,6 +1844,9 @@ impl Wallet {
.graph()
.list_canonical_txs(&self.chain, chain_tip)
.filter(|canon_tx| prev_txids.contains(&canon_tx.tx_node.txid))
// This is for a small performance gain. Although `.filter` filters out excess txs, it
// will still consume the internal `CanonicalIter` entirely. Having a `.take` here
// allows us to stop further unnecessary canonicalization.
.take(prev_txids.len())
.map(|canon_tx| {
let txid = canon_tx.tx_node.txid;
Expand Down

0 comments on commit caa0f13

Please sign in to comment.