kernel: Use spans instead of vectors for passing block headers to validation functions#30742
kernel: Use spans instead of vectors for passing block headers to validation functions#30742achow101 merged 3 commits intobitcoin:masterfrom
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. |
|
Actually, I read this assuming we'd already migrated away from |
|
Relevant: #29119 |
|
Thanks for the review @theuni! Updated 65e4404 -> c584c1f (headersSpan_0 -> headersSpan_1, compare)
There already are users of |
|
Updated c584c1f -> 45a9005 (headersSpan_1 -> headersSpan_2, compare) |
|
Thanks for the review @jonatack. Updated 45a9005 -> 797eede (headersSpan_2 -> headersSpan_3, compare) |
Can you explain this a bit more? In theory there is C++26 with https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2447r6.html , but I don't think any compiler implements it and the code here is compiled in C++20, so I haven't checked if that fixes your problem. Currently in the code, you are even creating explicit copies via the Maybe I am missing something obvious? |
Thanks, you are right, my initial patch avoided copies where possible by explicitly creating the span, but the brace initializers that theuni suggested instead create temporary arrays that copy the headers. I should update the description, or I can revert to what I was doing before. Do you have a preference? I don't think the copies matter all that much either way. The main motiviation for me is that it makes life a bit easier for potential external callers if you use spans over vector references in the interfaces. |
|
I think your initial commit also had some calls to Maybe remove it from the motivation, since it doesn't seem to be a goal, and if it was a goal, it would be hard to achieve? |
Makes it friendlier for potential future users of the kernel library if they do not store the headers in a std::vector, but can guarantee contiguous memory.
Makes it friendlier for potential future users of the kernel library if they do not store the headers in a std::vector, but can guarantee contiguous memory.
|
797eede -> b31483e (headersSpan_3 -> headersSpan_4, compare)
|
|
This changes vector to span, and where copies were done previously, they are still done. ACK b31483e 🖍 Show signatureSignature: |
|
b31483e -> a2955f0 (headersSpan_4 -> headersSpan_5, compare)
|
Makes it friendlier for potential future users of the kernel library if they do not store the headers in a std::vector, but can guarantee contiguous memory.
|
re-ACK a2955f0 - no changes except further walking the |
|
ACK a2955f0 🕑 Show signatureSignature: |
|
CI failure looks unrelated and can be ignored: #30797 |
|
ACK a2955f0 |
Makes it friendlier for potential future users of the kernel library if they do not store the headers in a std::vector, but can guarantee contiguous memory.
Take this opportunity to also change the argument of ImportBlocks previously taking a
std::vectorto astd::span.