Separate out merge method into public trait#842
Separate out merge method into public trait#842sanket1729 merged 1 commit intorust-bitcoin:masterfrom
Conversation
|
What is the reason this is a trait and not inherent methods? Do people generally need to abstract over merging different items? |
|
I think it makes sense to have it as a trait, but I would envision the trait to be something more like Add. trait Merge<With> {
fn merge(&mut self, other: With) -> Result<(), Error>;
}So that we might be able to define more structured Merging (e.g., merge raw tx into PSBT, PSBT V1 into V2 but not V2 into V1, etc). However this is likely overkill v.s. as @Kixunil points out, an inherent method for it (which can also just be a wrapper around the Map type). |
|
@JeremyRubin if someone actually has need for that (which I won't believe until I see an actual real-life example of code abstractly working on those types) then we can add |
|
Seconding "let's make this an intrinsic method". Also, I'd like to call it |
0560f6d to
e88790e
Compare
|
Updated PR as suggested:
Also improved the unit tests
|
Recently we (*cough* Tobin) made the `Map` trait private and neglected to add a public API for combining together two PSBTs. Doing so broke the `psbt` module. Pull the merge logic out of the `Map` trait and put it in methods on each individual type (`Input`, `Output`, `PartiallySignedTransaction`). Doing so allows for simplification of return types since combining inputs/outputs never errors. Use the term 'combine' instead of 'merge' since that is the term used in BIP 174.
e88790e to
5e24499
Compare
|
i'm kinda meh on changing the name from merge / combine since it's a breaking change for no great reason. Can you add a deprecated wrapper around combine called merge? We can then remove it after a release or two... |
|
The old name was confusing and inconsistent with PSBT terminology, which is how it got deleted originally without anybody raising their eyebrows. But yes, we should put a deprecated wrapper around it. |
|
I don't think we can deprecate it because the API break was making |
|
If we really want to use deprecate we could make |
|
Ah, ok, sounds good. If the |
|
My point was that you can add an inherent method names merge that is the
same as combine, not make map a public trait
…On Thu, Feb 24, 2022, 7:36 AM Andrew Poelstra ***@***.***> wrote:
***@***.**** approved this pull request.
ACK 5e24499
<5e24499>
—
Reply to this email directly, view it on GitHub
<#842 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAGYN6ZFX3BMYOJ5Y4E7PO3U4ZGADANCNFSM5PBOBBZQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
@JeremyRubin it would be weird to add a new deprecated method that didn't exist before, even if it had the same name as a method on a deleted trait. |
|
Yeah, users would still get failure on non-existing trait. |
|
ah it used to exist as an inherent in 0.26 https://docs.rs/bitcoin/0.26.2/bitcoin/util/psbt/struct.PartiallySignedTransaction.html#method.merge, i guess in 0.27 it was moved to the trait, I wasn't sure when the refactor to Map was (altho it looks like it was a part of 0.27) |
|
Lol, given that it existed in 0.26 I actually wouldn't mind re-adding and deprecating it now. But I would mildly prefer not to. |
|
whatever works! |
sanket1729
left a comment
There was a problem hiding this comment.
ACK 5e24499. Also verified that the vectors are same of that of BIP174
Recently we (cough Tobin) made the
Maptrait private and neglectedto add a public API for merging together two PSBTs. Doing so broke the
psbtmodule.Add a public trait
Mergeand implement it forPartiallySignedTransactionusing the code currently in themergemethod of the now private
Maptrait.Motivated by #841