Introduce BigEndian wrapper and use it for netaddress ports #12916

pull sipa wants to merge 1 commits into bitcoin:master from sipa:201804_beport changing 2 files +50 −8
  1. sipa commented at 4:40 pm on April 8, 2018: member

    This is another small improvement taken from #10785.

    Instead of manually converting from/to BE format in the CService serializer, provide a generic way in serialize.h to serialize BE data (only 16 bits for now).

  2. MarcoFalke added the label Refactoring on Apr 8, 2018
  3. Introduce BigEndian wrapper and use it for netaddress ports ece88fd269
  4. in src/serialize.h:440 in a48a8976c4 outdated
    435+    }
    436+
    437+    template<typename Stream>
    438+    void Serialize(Stream& s) const
    439+    {
    440+        if (sizeof(I) == 2) ser_writedata16be(s, m_val);
    


    promag commented at 9:54 pm on April 8, 2018:
    Why these checks if (sizeof(I) == 2)?

    sipa commented at 9:56 pm on April 8, 2018:
    To more easily extend this later (if needed) to other sizes. I can get rid of them if that’s confusing (they’re always known at compile time).

    promag commented at 10:00 pm on April 8, 2018:
    At the moment is confusing/redundant because of the static assert above. Keep it simple?

    sipa commented at 10:32 pm on April 8, 2018:
    Fixed.
  5. sipa force-pushed on Apr 8, 2018
  6. sipa commented at 10:33 pm on April 8, 2018: member
    Removed the if (sizeof(I) == 2) clauses, and added extra comments and checks.
  7. promag commented at 10:42 pm on April 8, 2018: member

    utACK ece88fd.

    Makes sense to also replace unsigned short port and unsigned short GetPort() with uint16_t?

  8. laanwj merged this on Apr 11, 2018
  9. laanwj closed this on Apr 11, 2018

  10. laanwj referenced this in commit 7b6041d1a7 on Apr 11, 2018
  11. deadalnix referenced this in commit 334205c83d on Apr 22, 2020
  12. ftrader referenced this in commit ce6edaacdf on Aug 17, 2020
  13. UdjinM6 referenced this in commit f8ac5a555b on Dec 17, 2020
  14. furszy referenced this in commit 5c93f159bc on Jul 5, 2021
  15. random-zebra referenced this in commit b4751e10ce on Aug 11, 2021
  16. MarcoFalke locked this on Sep 8, 2021

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

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