diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2018-04-04 12:40:10 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2018-04-05 08:20:37 -0700 |
commit | 9272d70536287d4ff9aa1ee41a401465c0e8194a (patch) | |
tree | 04ba75bd2a66ecec47a47e4e1883f07ac07775e0 /src/netaddress.h | |
parent | 833bc085835dd1bcd8c0fc2a25aa746b7d6fe012 (diff) |
Support serializing Span<unsigned char> and use that instead of FLATDATA
Diffstat (limited to 'src/netaddress.h')
-rw-r--r-- | src/netaddress.h | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/netaddress.h b/src/netaddress.h index ad6b55eb58..b3d1407f72 100644 --- a/src/netaddress.h +++ b/src/netaddress.h @@ -11,6 +11,7 @@ #include <compat.h> #include <serialize.h> +#include <span.h> #include <stdint.h> #include <string> @@ -167,10 +168,13 @@ class CService : public CNetAddr template <typename Stream, typename Operation> inline void SerializationOp(Stream& s, Operation ser_action) { READWRITE(ip); + + // TODO: introduce native support for BE serialization in serialize.h unsigned short portN = htons(port); - READWRITE(FLATDATA(portN)); - if (ser_action.ForRead()) + READWRITE(Span<unsigned char>((unsigned char*)&portN, 2)); + if (ser_action.ForRead()) { port = ntohs(portN); + } } }; |