-
Notifications
You must be signed in to change notification settings - Fork 745
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Prevouts::All(&[TxOut]) to Prevouts::All(&[&TxOut]) #835
Conversation
I'm not convinced by this. This change helps the caller who already has |
Yup, exactly I am not sure how to evaluate this. For the psbt workflow, Having I can also imagine someone asking a full node |
IMO we should try generics with |
115e0f6
to
5943e40
Compare
@Kixunil, iterator turned out more annoying(requiring exact size iterators and cloning while consuming) and unneeded for this application. But the borrow::Borrow helped a lot. I believe this satisfies my use-case while retaining the current use-case too. |
5943e40
to
27ff05e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, yeah, Borrow
on item in the array looks good!
@@ -988,7 +997,7 @@ mod tests { | |||
let prevouts = if sighash_type.split_anyonecanpay_flag().1 && tx_bytes[0] % 2 == 0 { | |||
// for anyonecanpay the `Prevouts::All` variant is good anyway, but sometimes we want to | |||
// test other codepaths | |||
Prevouts::One(input_index, &prevouts[input_index]) | |||
Prevouts::One(input_index, prevouts[input_index].clone()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This clone was done because the generic T
needed to be the same type across if else arms
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Doesn't matter much in test anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, just highlighted because it might confuse review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is kinda unfortunate because it might be a common pattern, but I don't see any sensible way around it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The taproot_signature_hash
function also gets the correct data for sighash single from prevouts::All. I think it is required to extract the corresponding txout from an array in this fashion. This was only done to test that both of these work.
This avoids some allocation of creating a vec of TxOut to create a slice incase the data is already available in psbt/other methods. Facilitates creation of Prevouts from &[TxOut] as well as &[&TxOut]
27ff05e
to
10fedfb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 10fedfb
TIL about Borrow
. Seems like it's a strictly more useful AsRef
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 10fedfb
I believe this avoids some allocation of creating a vec of TxOut to
create a slice incase the data is already available in psbt/other
methods.
See #834