Skip to content

Commit 91b940a

Browse files
evanlinjinruben
authored andcommitted
docs(wallet): Explain .take usage
1 parent f8b4f91 commit 91b940a

File tree

1 file changed

+3
-0
lines changed
  • crates/wallet/src/wallet

1 file changed

+3
-0
lines changed

crates/wallet/src/wallet/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1844,6 +1844,9 @@ impl Wallet {
18441844
.graph()
18451845
.list_canonical_txs(&self.chain, chain_tip)
18461846
.filter(|canon_tx| prev_txids.contains(&canon_tx.tx_node.txid))
1847+
// This is for a small performance gain. Although `.filter` filters out excess txs, it
1848+
// will still consume the internal `CanonicalIter` entirely. Having a `.take` here
1849+
// allows us to stop further unnecessary canonicalization.
18471850
.take(prev_txids.len())
18481851
.map(|canon_tx| {
18491852
let txid = canon_tx.tx_node.txid;

0 commit comments

Comments
 (0)