]> Untitled Git - bdk/commitdiff
Merge bitcoindevkit/bdk#1586: Change methods of `IndexedTxGraph`/`TxGraph`/`Wallet...
authorSteve Myers <steve@notmandatory.org>
Mon, 9 Sep 2024 19:58:20 +0000 (14:58 -0500)
committerSteve Myers <steve@notmandatory.org>
Mon, 9 Sep 2024 19:58:47 +0000 (14:58 -0500)
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<Transaction>` 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<Arc<Transaction>>`, 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<Arc<Transaction>>` and be non-breaking (since `Arc<T>` impls `From<T>` 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<Arc<Transaction>>` instead of `Transaction` or `&Transaction`.
  * Changed `TxGraph` method `batch_insert_unconfirmed` to take in `T: Into<Arc<Transaction>>` instead of `Transaction`.
  * Changed `Wallet` methods `insert_tx`, `apply_unconfirmed_txs` to take in `T: Into<Arc<Transaction>>` 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

1  2 
crates/wallet/src/wallet/mod.rs
example-crates/wallet_rpc/src/main.rs

Simple merge
Simple merge