mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 06:58:57 +01:00
rework overhauled serialization methods to non-static
Thanks to Pieter Wuille for most of the work on this commit. I did not fixup the overhaul commit, because a rebase conflicted with "remove fields of ser_streamplaceholder". I prefer not to risk making a mistake while resolving it.
This commit is contained in:
@@ -35,15 +35,15 @@ class CMessageHeader
|
||||
std::string GetCommand() const;
|
||||
bool IsValid() const;
|
||||
|
||||
IMPLEMENT_SERIALIZE
|
||||
IMPLEMENT_SERIALIZE;
|
||||
|
||||
template <typename T, typename Stream, typename Operation>
|
||||
inline static size_t SerializationOp(T thisPtr, Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
template <typename Stream, typename Operation>
|
||||
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
size_t nSerSize = 0;
|
||||
READWRITE(FLATDATA(thisPtr->pchMessageStart));
|
||||
READWRITE(FLATDATA(thisPtr->pchCommand));
|
||||
READWRITE(thisPtr->nMessageSize);
|
||||
READWRITE(thisPtr->nChecksum);
|
||||
READWRITE(FLATDATA(pchMessageStart));
|
||||
READWRITE(FLATDATA(pchCommand));
|
||||
READWRITE(nMessageSize);
|
||||
READWRITE(nChecksum);
|
||||
return nSerSize;
|
||||
}
|
||||
|
||||
@@ -87,14 +87,14 @@ class CAddress : public CService
|
||||
|
||||
void Init();
|
||||
|
||||
IMPLEMENT_SERIALIZE
|
||||
IMPLEMENT_SERIALIZE;
|
||||
|
||||
template <typename T, typename Stream, typename Operation>
|
||||
inline static size_t SerializationOp(T thisPtr, Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
template <typename Stream, typename Operation>
|
||||
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
size_t nSerSize = 0;
|
||||
bool fRead = boost::is_same<Operation, CSerActionUnserialize>();
|
||||
|
||||
CAddress* pthis = const_cast<CAddress*>(thisPtr);
|
||||
CAddress* pthis = const_cast<CAddress*>(this);
|
||||
CService* pip = (CService*)pthis;
|
||||
if (fRead)
|
||||
pthis->Init();
|
||||
@@ -102,8 +102,8 @@ class CAddress : public CService
|
||||
READWRITE(nVersion);
|
||||
if ((nType & SER_DISK) ||
|
||||
(nVersion >= CADDR_TIME_VERSION && !(nType & SER_GETHASH)))
|
||||
READWRITE(thisPtr->nTime);
|
||||
READWRITE(thisPtr->nServices);
|
||||
READWRITE(nTime);
|
||||
READWRITE(nServices);
|
||||
READWRITE(*pip);
|
||||
|
||||
return nSerSize;
|
||||
@@ -128,13 +128,13 @@ class CInv
|
||||
CInv(int typeIn, const uint256& hashIn);
|
||||
CInv(const std::string& strType, const uint256& hashIn);
|
||||
|
||||
IMPLEMENT_SERIALIZE
|
||||
IMPLEMENT_SERIALIZE;
|
||||
|
||||
template <typename T, typename Stream, typename Operation>
|
||||
inline static size_t SerializationOp(T thisPtr, Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
template <typename Stream, typename Operation>
|
||||
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
|
||||
size_t nSerSize = 0;
|
||||
READWRITE(thisPtr->type);
|
||||
READWRITE(thisPtr->hash);
|
||||
READWRITE(type);
|
||||
READWRITE(hash);
|
||||
return nSerSize;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user