net: Treat raw message bytes as uint8_t #20432

pull MarcoFalke wants to merge 1 commits into bitcoin:master from MarcoFalke:2011-netBytesUint8 changing 6 files +19 −19
  1. MarcoFalke commented at 9:25 AM on November 20, 2020: member

    Using uint8_t from the beginning when messages are recved has two style benefits:

    • The signedness is clear from reading the code, as it does not depend on the architecture
    • When passing the bytes on, the need for static signedness casts is dropped, making the code a bit less verbose and more coherent
  2. MarcoFalke added the label Refactoring on Nov 20, 2020
  3. MarcoFalke added the label P2P on Nov 20, 2020
  4. MarcoFalke force-pushed on Nov 20, 2020
  5. jnewbery commented at 11:10 AM on November 20, 2020: member

    Should std::byte be used for raw bytes now that we're on c++17?

  6. promag commented at 11:12 AM on November 20, 2020: member

    Concept ACK, @jnewbery :+1:

  7. MarcoFalke commented at 11:19 AM on November 20, 2020: member

    I don't think we can use std::byte because it is type-safe. Using it would require changing all code (net, hashes, ...) or adding verbose wrappers again.

  8. fanquake commented at 1:17 PM on November 20, 2020: member

    Don't you just hate it when too much type safety gets in the way of using the standard library.

  9. net: Treat raw message bytes as uint8_t fabecce719
  10. MarcoFalke force-pushed on Nov 20, 2020
  11. laanwj commented at 9:10 AM on November 21, 2020: member

    Concept ACK

    I was personally never convinced that std::byte adds that much type safety over using unsigned 8-bit integers as bytes (which at least makes manipulating them architecture-independent, without signedness sharp edges). I like uint8_t myself.

  12. theStack approved
  13. theStack commented at 10:27 AM on November 22, 2020: member

    Code Review ACK fabecce71909c984504c21fa05f91d5f1b471e8c

  14. practicalswift commented at 11:10 AM on November 22, 2020: contributor

    Concept ACK

  15. laanwj commented at 8:45 AM on November 23, 2020: member

    I like how this gets rid of all the casts except the one at the OS boundary (recv). no more casting back and forth. CDataStream next? :smile:

    Code review ACK fabecce71909c984504c21fa05f91d5f1b471e8c

  16. jonatack commented at 9:13 AM on November 23, 2020: member

    Tested ACK fabecce71909c984504c21fa05f91d5f1b471e8c

  17. laanwj merged this on Nov 23, 2020
  18. laanwj closed this on Nov 23, 2020

  19. MarcoFalke deleted the branch on Nov 23, 2020
  20. sidhujag referenced this in commit c1873f7ad0 on Nov 23, 2020
  21. MarcoFalke commented at 7:09 PM on November 23, 2020: member

    CDataStream next? :smile:

    Done in #20464 :sweat_smile:

  22. DrahtBot locked this on Feb 15, 2022

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: 2026-04-17 06:14 UTC

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