aboutsummaryrefslogtreecommitdiff
path: root/src/netaddress.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/netaddress.h')
-rw-r--r--src/netaddress.h8
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);
+ }
}
};