diff options
| author | Pieter Wuille <[email protected]> | 2018-04-08 09:39:05 -0700 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2018-04-08 15:31:01 -0700 |
| commit | ece88fd26995350dfaa4675b4291605a20203527 (patch) | |
| tree | 580a594a66289796f73812d5a5f98c5a0d8d4476 /src/netaddress.h | |
| parent | Merge #12886: Introduce Span type and use it instead of FLATDATA (diff) | |
| download | discoin-ece88fd26995350dfaa4675b4291605a20203527.tar.xz discoin-ece88fd26995350dfaa4675b4291605a20203527.zip | |
Introduce BigEndian wrapper and use it for netaddress ports
Diffstat (limited to 'src/netaddress.h')
| -rw-r--r-- | src/netaddress.h | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/netaddress.h b/src/netaddress.h index b3d1407f7..38f870925 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)); } }; |