From: Steve Myers Date: Mon, 9 Sep 2024 19:58:20 +0000 (-0500) Subject: Merge bitcoindevkit/bdk#1586: Change methods of `IndexedTxGraph`/`TxGraph`/`Wallet... X-Git-Tag: v1.0.0-beta.3~7 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/database/scripts/enum.Auth.html?a=commitdiff_plain;h=8760653339d3a4c66dfa9a54a7b9d943a065f924;p=bdk Merge bitcoindevkit/bdk#1586: Change methods of `IndexedTxGraph`/`TxGraph`/`Wallet` that insert txs to be more generic 87e61212f556bccfaa2a64b74f727cedc0f70e9c feat(chain,wallet)!: change methods to take in generic instead of `&Transaction` (志宇) c39284d8299c5a8b34b73ce947e93425d5cdc121 feat(wallet): make `Wallet::insert_tx` generic (志宇) 67d5fa695f3f748d176c182d25be5ef70f5127ed feat(chain): make various insert tx methods more generic (志宇) Pull request description: ### Description We want to reuse the `Arc` pointer whenever possible. However, some methods on `TxGraph` and `IndexedTxGraph` that insert transactions take in `&Transaction` or `Transaction` (thus forcing us to create a new `Arc` internally by cloning, even if the input tx is under a `Arc`). This PR changes these methods to take in a generic parameter, `T: Into>`, allowing us to reuse the `Arc` pointer whenever possible. ### Notes to the reviewers Methods that previously took in `Transaction` can be changed to take in `T: Into>` and be non-breaking (since `Arc` impls `From` automatically). These changes are contained in the first two commits. Methods that previously took in `&Transaction` will break. However, I think these api changes are small and the improvements are substantial enough to be worth it. These changes are contained in the last commit. ### Changelog notice * Changed `IndexedTxGraph` methods `insert_tx`, `batch_insert_relevant`, `batch_insert_relevant_unconfirmed`, `batch_insert_unconfirmed` to take in `T: Into>` instead of `Transaction` or `&Transaction`. * Changed `TxGraph` method `batch_insert_unconfirmed` to take in `T: Into>` instead of `Transaction`. * Changed `Wallet` methods `insert_tx`, `apply_unconfirmed_txs` to take in `T: Into>` instead of `Transaction` or `&Transaction`. ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo fmt` and `cargo clippy` before committing ACKs for top commit: oleonardolima: utACK 87e61212f556bccfaa2a64b74f727cedc0f70e9c notmandatory: ACK 87e61212f556bccfaa2a64b74f727cedc0f70e9c Tree-SHA512: 6be8cde80984caaaf544fa5738bc4de39428cd4cd352d242ecb73d7cf2e69794c869249e76653a32a47bb5d19e4b3a47036e063cdd32ad47642b44c99cb7ee7c --- 8760653339d3a4c66dfa9a54a7b9d943a065f924