Repository navigation
Conversation
Expose the consensus serialization of a witness stack, so all of its items can be read in a single call.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Yuvicc, thanks for putting this up. It looks like it comes down to where the items are decoded. What I'm trying to accomplish is to make an efficient form of the design that the API already has ( |
Thanks, that's a fair summary. With the switch to
I'll leave this open for now so other reviewers can weigh in on which approach they'd prefer for the API. |
|
Approach NACK, I think we can ~keep the current interface and let the implementation handle this as per #36909 (comment). Also, the complexity is still O(n) on master currently, so this should at the very least be drafted until/when #36895 or equivalent is merged. |
|
Closing for now. |
|
I ran some numbers that might be relevant to whether a Since #36909 discussion is now leaning towards the witness stack copying the items into its own buffer (diff), I benchmarked that version from the Go bindings on mainnet block 840000 (3765 inputs, 6826 witness items), reading every witness item of every input:
The saving comes from crossing between Go and C once per input instead of once per item. I put the |

I agree the O(n²) cost of reading a whole witness with
btck_witness_stack_get_item_atneeds fixing. I'm less sure a new callback type is the best way to do it which #36909 is doing. Instead we could expose the witness's serialized bytes and let the bindings or caller decide how to decode them, this also follows the*_to_bytesfunctions we already have in the API.