mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 14:38:29 +01:00
Merge #18317: Serialization improvements step 6 (all except wallet/gui)
f9ee0f37c2Add comments to CustomUintFormatter (Pieter Wuille)4eb5643e35Convert everything except wallet/qt to new serialization (Pieter Wuille)2b1f85e8c5Convert blockencodings_tests to new serialization (Pieter Wuille)73747afbbeConvert merkleblock to new serialization (Pieter Wuille)d06fedd1bcAdd SER_READ and SER_WRITE for read/write-dependent statements (Russell Yanofsky)6f9a1e5ad0Extend CustomUintFormatter to support enums (Russell Yanofsky)769ee5fa00Merge BigEndian functionality into CustomUintFormatter (Pieter Wuille) Pull request description: The next step of changes from #10785. This: * Adds support for enum serialization to `CustomUintFormatter`, used in `CAddress` for service flags. * Merges `BigEndian` into `CustomUintFormatter`, used in `CNetAddr` for port numbers. * Converts everything (except wallet and gui) to use the new serialization framework. ACKs for top commit: MarcoFalke: re-ACKf9ee0f37c2, only change is new documentation commit for CustomUintFormatter 📂 ryanofsky: Code review ACKf9ee0f37c2. Just new commit adding comment since last review jonatack: Code review re-ACKf9ee0f37c2only change since last review is an additional commit adding Doxygen documentation for `CustomUintFormatter`. Tree-SHA512: e7a0a36afae592d5a4ff8c81ae04d858ac409388e361f2bc197d9a78abca45134218497ab2dfd6d031e0cce0ca586cf857077b7c6ce17fccf67e2d367c1b6cd4
This commit is contained in:
@@ -46,16 +46,7 @@ public:
|
||||
std::string GetCommand() const;
|
||||
bool IsValid(const MessageStartChars& messageStart) const;
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
template <typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action)
|
||||
{
|
||||
READWRITE(pchMessageStart);
|
||||
READWRITE(pchCommand);
|
||||
READWRITE(nMessageSize);
|
||||
READWRITE(pchChecksum);
|
||||
}
|
||||
SERIALIZE_METHODS(CMessageHeader, obj) { READWRITE(obj.pchMessageStart, obj.pchCommand, obj.nMessageSize, obj.pchChecksum); }
|
||||
|
||||
char pchMessageStart[MESSAGE_START_SIZE];
|
||||
char pchCommand[COMMAND_SIZE];
|
||||
@@ -343,23 +334,19 @@ public:
|
||||
|
||||
void Init();
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
template <typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action)
|
||||
SERIALIZE_METHODS(CAddress, obj)
|
||||
{
|
||||
if (ser_action.ForRead())
|
||||
Init();
|
||||
SER_READ(obj, obj.Init());
|
||||
int nVersion = s.GetVersion();
|
||||
if (s.GetType() & SER_DISK)
|
||||
if (s.GetType() & SER_DISK) {
|
||||
READWRITE(nVersion);
|
||||
}
|
||||
if ((s.GetType() & SER_DISK) ||
|
||||
(nVersion >= CADDR_TIME_VERSION && !(s.GetType() & SER_GETHASH)))
|
||||
READWRITE(nTime);
|
||||
uint64_t nServicesInt = nServices;
|
||||
READWRITE(nServicesInt);
|
||||
nServices = static_cast<ServiceFlags>(nServicesInt);
|
||||
READWRITEAS(CService, *this);
|
||||
(nVersion >= CADDR_TIME_VERSION && !(s.GetType() & SER_GETHASH))) {
|
||||
READWRITE(obj.nTime);
|
||||
}
|
||||
READWRITE(Using<CustomUintFormatter<8>>(obj.nServices));
|
||||
READWRITEAS(CService, obj);
|
||||
}
|
||||
|
||||
ServiceFlags nServices;
|
||||
@@ -395,14 +382,7 @@ public:
|
||||
CInv();
|
||||
CInv(int typeIn, const uint256& hashIn);
|
||||
|
||||
ADD_SERIALIZE_METHODS;
|
||||
|
||||
template <typename Stream, typename Operation>
|
||||
inline void SerializationOp(Stream& s, Operation ser_action)
|
||||
{
|
||||
READWRITE(type);
|
||||
READWRITE(hash);
|
||||
}
|
||||
SERIALIZE_METHODS(CInv, obj) { READWRITE(obj.type, obj.hash); }
|
||||
|
||||
friend bool operator<(const CInv& a, const CInv& b);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user