mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-06 11:13:02 +02:00
Support serializing Span<unsigned char> and use that instead of FLATDATA
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user