Skip to content

Review feedback from #4 #7

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

Merged
merged 1 commit into from
Mar 2, 2021
Merged

Review feedback from #4 #7

merged 1 commit into from
Mar 2, 2021

Conversation

sanket1729
Copy link
Member

@sanket1729 sanket1729 commented Mar 2, 2021

Based on @apoelstra's comment https://github.com/sanket1729/elements-miniscript/pull/4#issuecomment-788104864

@sanket1729 sanket1729 changed the title Review feedback Review feedback from #4 Mar 2, 2021
@@ -633,7 +633,7 @@ impl StackCtxOperations for script::Builder {
let mut builder = self;
// Initial Witness
let max_elems = MAX_SCRIPT_ELEMENT_SIZE / MAX_STANDARD_P2WSH_STACK_ITEM_SIZE;
for _ in 0..(max_elems - 1) {
for _ in 0..max_elems {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This took me a bit of thinking :) I think that max_elems is misleadingly named because it's actually one less than the maximum number of elements. I think it'd be better to leave the - 1 in place (no parentheses are needed btw) and to change

        let max_elems = MAX_SCRIPT_ELEMENT_SIZE / MAX_STANDARD_P2WSH_STACK_ITEM_SIZE;
```
to
    let max_elems = (MAX_SCRIPT_ELEMENT_SIZE + MAX_STANDARD_P2WSH_STACK_ITEM_SIZE - 1) / MAX_STANDARD_P2WSH_STACK_ITEM_SIZE;

```
or even just

        let max_elems = MAX_SCRIPT_ELEMENT_SIZE / MAX_STANDARD_P2WSH_STACK_ITEM_SIZE + 1;

since these numbers are fixed and we know that one is not a multiple of the other.

Copy link
Member

@apoelstra apoelstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack 15e117f

@sanket1729 sanket1729 merged commit ab90ad5 into master Mar 2, 2021
@sanket1729 sanket1729 deleted the covenants branch March 2, 2021 22:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants