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

pull maflcko wants to merge 2 commits into bitcoin:master from maflcko:2306-fs_stuff- changing 4 files +14 −6
  1. maflcko 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. maflcko 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.

    maflcko 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.
  15. kwvg referenced this in commit 9a1195e695 on Feb 20, 2024
  16. kwvg referenced this in commit 67d82ce231 on Feb 23, 2024
  17. kwvg referenced this in commit 2737b6d412 on Feb 23, 2024
  18. kwvg referenced this in commit 35084f97f6 on Feb 23, 2024
  19. kwvg referenced this in commit a8f1000a01 on Feb 23, 2024
  20. kwvg referenced this in commit a73a01d9a5 on Feb 24, 2024
  21. kwvg referenced this in commit b3d204e02b on Feb 24, 2024
  22. kwvg referenced this in commit 731d28a3c0 on Feb 27, 2024
  23. PastaPastaPasta referenced this in commit 2b26a87874 on Feb 28, 2024
  24. PastaPastaPasta referenced this in commit 96c4442253 on Feb 28, 2024
  25. bitcoin locked this on Jul 11, 2024

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-11-21 09:12 UTC

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