Add apply_unconfirmed_txs_events and apply_evicted_txs_events#388
Add apply_unconfirmed_txs_events and apply_evicted_txs_events#388notmandatory wants to merge 1 commit intobitcoindevkit:masterfrom
Conversation
|
Per discussion in #374 I'm happy to deprecate these _events functions and replace them with some sort of If we agree to go this direction for 3.0 then I'll finish adding tests and cherry-pick these commits back to the release/2.x branch. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #388 +/- ##
==========================================
+ Coverage 79.17% 79.73% +0.56%
==========================================
Files 24 24
Lines 5311 5296 -15
Branches 242 242
==========================================
+ Hits 4205 4223 +18
+ Misses 1029 996 -33
Partials 77 77
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
4883f54 to
c845417
Compare
|
Added a couple simple tests. Ready for review. |
…events - refactor _events functions to use new wallet_txs_to_map helper
c845417 to
01b1559
Compare
|
Updated with a couple changes suggested by @ValuedMammal (and also by Claude, will get it to review patches before pushing next time 🤖 ).
|
| fn wallet_txs_to_map<'a>( | ||
| txs: impl Iterator<Item = crate::WalletTx<'a>>, | ||
| ) -> BTreeMap<Txid, (Arc<Transaction>, ChainPosition<ConfirmationBlockTime>)> { | ||
| txs.map(|wtx| { | ||
| ( | ||
| wtx.tx_node.txid, | ||
| (wtx.tx_node.tx.clone(), wtx.chain_position), | ||
| ) | ||
| }) | ||
| .collect() | ||
| } |
There was a problem hiding this comment.
nit: It'd be nice if you could call it as self.map_transactions().
| fn wallet_txs_to_map<'a>( | |
| txs: impl Iterator<Item = crate::WalletTx<'a>>, | |
| ) -> BTreeMap<Txid, (Arc<Transaction>, ChainPosition<ConfirmationBlockTime>)> { | |
| txs.map(|wtx| { | |
| ( | |
| wtx.tx_node.txid, | |
| (wtx.tx_node.tx.clone(), wtx.chain_position), | |
| ) | |
| }) | |
| .collect() | |
| } | |
| fn map_transactions( | |
| &self, | |
| ) -> BTreeMap<Txid, (Arc<Transaction>, ChainPosition<ConfirmationBlockTime>)> { | |
| self.transactions() | |
| .map(|canonical_tx| { | |
| ( | |
| canonical_tx.tx_node.txid, | |
| (canonical_tx.tx_node.tx, canonical_tx.chain_position), | |
| ) | |
| }) | |
| .collect() | |
| } |
Description
fixes #374
Notes to the reviewers
To reduce duplicate code I also refactored all the _events functions to use new
wallet_txs_to_maphelper.Changelog notice
Checklists
All Submissions:
just pbefore pushingNew Features: