mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-08 13:49:35 +02:00
Introduce BigEndian wrapper and use it for netaddress ports
This commit is contained in:
@@ -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));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user