-
Notifications
You must be signed in to change notification settings - Fork 0
Closed
Description
Context
In sync.rs, the existing_tx_map HashMap is built in three places with inconsistent key types:
| Location | Function | Key type |
|---|---|---|
| ~line 414 | process_wallet_transactions |
HashMap<String, &_> (clones each txid) |
| ~line 1545 | check_address_watch_for_confirmations |
HashMap<&str, &_> (borrows, zero-copy) |
| ~line 1832 | check_grouped_address_watch_for_confirmations |
HashMap<&str, &_> (borrows, zero-copy) |
The &str-keyed maps avoid heap allocation per entry. The main process_wallet_transactions function should use the same &str borrowing pattern for consistency and to avoid unnecessary String clones.
Proposed fix
Change line ~414 from:
let existing_tx_map: HashMap<String, &TransactionWithWallet> = existing_transactions
.iter()
.map(|tx| (tx.txid.clone(), tx))
.collect();To:
let existing_tx_map: HashMap<&str, &TransactionWithWallet> = existing_transactions
.iter()
.map(|tx| (tx.txid.as_str(), tx))
.collect();This requires updating lookup call sites to use .get(txid.as_str()) instead of .get(txid) where the key is a String.
Identified during PR #245 code review.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels