util: Allow FastRandomContext::randbytes for std::byte, Allow std::byte serialization #28012

pull MarcoFalke wants to merge 2 commits into bitcoin:master from MarcoFalke:2306-fs_stuff- changing 4 files +14 −6
  1. MarcoFalke commented at 10:14 am on June 30, 2023: member
    I need this for some stuff, but it should also be useful by itself for other developers that need it.
  2. Allow FastRandomContext::randbytes for all byte types fade43edc4
  3. Allow std::byte serialization fac6af16f4
  4. DrahtBot commented at 10:14 am on June 30, 2023: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK sipa, dergoegge

    If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update.

  5. DrahtBot renamed this:
    util: Allow FastRandomContext::randbytes for std::byte, Allow std::byte serialization
    util: Allow FastRandomContext::randbytes for std::byte, Allow std::byte serialization
    on Jun 30, 2023
  6. DrahtBot added the label Utils/log/libs on Jun 30, 2023
  7. sipa commented at 6:27 pm on June 30, 2023: member

    utACK fac6af16f4a254458b8cb3522317422b40362f8d

    The two commits feel quite unrelated here, though, but both seem fine to me.

  8. dergoegge approved
  9. dergoegge commented at 8:33 am on July 7, 2023: member
    Code review ACK fac6af16f4a254458b8cb3522317422b40362f8d
  10. fanquake merged this on Jul 7, 2023
  11. fanquake closed this on Jul 7, 2023

  12. sidhujag referenced this in commit b3c7e68a27 on Jul 7, 2023
  13. MarcoFalke deleted the branch on Jul 8, 2023
  14. in src/random.h:215 in fac6af16f4
    210@@ -211,7 +211,8 @@ class FastRandomContext
    211     }
    212 
    213     /** Generate random bytes. */
    214-    std::vector<unsigned char> randbytes(size_t len);
    215+    template <typename B = unsigned char>
    216+    std::vector<B> randbytes(size_t len);
    


    jonatack commented at 5:32 pm on July 12, 2023:
    Why this change? It is currently unused, “I need this for some stuff” is vague, and this change is being cited in #27425 (review) as a reason not to use rand test helpers consistently.

    MarcoFalke commented at 5:39 pm on July 12, 2023:
    std::byte is used in many places to pass bytes. Adding this helper makes it easier to fill a vector with std::bytes. For example, it is used in 9999a49b3299bd25dde4805f5c68adef3876057f (https://github.com/bitcoin/bitcoin/pull/28060). But the helper can also be used in other places.

    jonatack commented at 5:43 pm on July 12, 2023:
    Thank you for clarifying for me.

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-07-08 22:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me