Change methods of IndexedTxGraph
/TxGraph
/Wallet
that insert txs to be more generic
#1586
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
We want to reuse the
Arc
pointer whenever possible. However, some methods onTxGraph
andIndexedTxGraph
that insert transactions take in&Transaction
orTransaction
(thus forcing us to create a newArc<Transaction>
internally by cloning, even if the input tx is under aArc
).This PR changes these methods to take in a generic parameter,
T: Into<Arc<Transaction>>
, allowing us to reuse theArc
pointer whenever possible.Notes to the reviewers
Methods that previously took in
Transaction
can be changed to take inT: Into<Arc<Transaction>>
and be non-breaking (sinceArc<T>
implsFrom<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
IndexedTxGraph
methodsinsert_tx
,batch_insert_relevant
,batch_insert_relevant_unconfirmed
,batch_insert_unconfirmed
to take inT: Into<Arc<Transaction>>
instead ofTransaction
or&Transaction
.TxGraph
methodbatch_insert_unconfirmed
to take inT: Into<Arc<Transaction>>
instead ofTransaction
.Wallet
methodsinsert_tx
,apply_unconfirmed_txs
to take inT: Into<Arc<Transaction>>
instead ofTransaction
or&Transaction
.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committing