diff options
Diffstat (limited to 'src/netbase.h')
| -rw-r--r-- | src/netbase.h | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/src/netbase.h b/src/netbase.h index 2df3c4474..9fc5c72eb 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -88,10 +88,12 @@ class CNetAddr friend bool operator!=(const CNetAddr& a, const CNetAddr& b); friend bool operator<(const CNetAddr& a, const CNetAddr& b); - IMPLEMENT_SERIALIZE - ( - READWRITE(FLATDATA(ip)); - ) + ADD_SERIALIZE_METHODS; + + template <typename Stream, typename Operation> + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + READWRITE(FLATDATA(ip)); + } }; class CSubNet @@ -148,15 +150,16 @@ class CService : public CNetAddr CService(const struct in6_addr& ipv6Addr, unsigned short port); CService(const struct sockaddr_in6& addr); - IMPLEMENT_SERIALIZE - ( - CService* pthis = const_cast<CService*>(this); - READWRITE(FLATDATA(ip)); - unsigned short portN = htons(port); - READWRITE(portN); - if (fRead) - pthis->port = ntohs(portN); - ) + ADD_SERIALIZE_METHODS; + + template <typename Stream, typename Operation> + inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { + READWRITE(FLATDATA(ip)); + unsigned short portN = htons(port); + READWRITE(portN); + if (ser_action.ForRead()) + port = ntohs(portN); + } }; typedef CService proxyType; @@ -182,4 +185,4 @@ bool CloseSocket(SOCKET& hSocket); /** Disable or enable blocking-mode for a socket */ bool SetSocketNonBlocking(SOCKET& hSocket, bool fNonBlocking); -#endif +#endif // BITCOIN_NETBASE_H |