aboutsummaryrefslogtreecommitdiff
path: root/src/netaddress.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2018-04-08 09:39:05 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2018-04-08 15:31:01 -0700
commitece88fd26995350dfaa4675b4291605a20203527 (patch)
tree580a594a66289796f73812d5a5f98c5a0d8d4476 /src/netaddress.h
parent97785863e2faa4a6d4e1130e300011985df0858c (diff)
Introduce BigEndian wrapper and use it for netaddress ports
Diffstat (limited to 'src/netaddress.h')
-rw-r--r--src/netaddress.h10
1 files changed, 2 insertions, 8 deletions
diff --git a/src/netaddress.h b/src/netaddress.h
index b3d1407f72..38f8709257 100644
--- a/src/netaddress.h
+++ b/src/netaddress.h
@@ -141,7 +141,7 @@ class CSubNet
class CService : public CNetAddr
{
protected:
- unsigned short port; // host order
+ uint16_t port; // host order
public:
CService();
@@ -168,13 +168,7 @@ 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(Span<unsigned char>((unsigned char*)&portN, 2));
- if (ser_action.ForRead()) {
- port = ntohs(portN);
- }
+ READWRITE(WrapBigEndian(port));
}
};