Use CSizeComputer to avoid counting sizes in SerializationOp

This commit is contained in:
Pieter Wuille 2014-08-21 00:49:32 +02:00 committed by Kamil Domanski
parent 84881f8c47
commit 31e9a8384a
13 changed files with 81 additions and 184 deletions

View file

@ -49,14 +49,11 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
CAddress* pthis = (CAddress*)(this);
READWRITE(*pthis);
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(*(CAddress*)this);
READWRITE(source);
READWRITE(nLastSuccess);
READWRITE(nAttempts);
return nSerSize;
}
void Init()

View file

@ -49,8 +49,7 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(this->nVersion);
nVersion = this->nVersion;
READWRITE(nRelayUntil);
@ -66,7 +65,6 @@ public:
READWRITE(LIMITED_STRING(strComment, 65536));
READWRITE(LIMITED_STRING(strStatusBar, 256));
READWRITE(LIMITED_STRING(strReserved, 256));
return nSerSize;
}
void SetNull();
@ -89,11 +87,9 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(vchMsg);
READWRITE(vchSig);
return nSerSize;
}
void SetNull();

View file

@ -65,13 +65,11 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(vData);
READWRITE(nHashFuncs);
READWRITE(nTweak);
READWRITE(nFlags);
return nSerSize;
}
void insert(const std::vector<unsigned char>& vKey);

View file

@ -34,10 +34,8 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(FLATDATA(*this));
return nSerSize;
}
void SetNull() { hash = 0; n = (uint32_t) -1; }
@ -96,12 +94,10 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(prevout);
READWRITE(scriptSig);
READWRITE(nSequence);
return nSerSize;
}
bool IsFinal() const
@ -152,10 +148,8 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(nSatoshisPerK);
return nSerSize;
}
};
@ -179,11 +173,9 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(nValue);
READWRITE(scriptPubKey);
return nSerSize;
}
void SetNull()
@ -264,9 +256,8 @@ public:
IMPLEMENT_SERIALIZE;
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>();
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
bool fRead = ser_action.ForRead();
READWRITE(*const_cast<int32_t*>(&this->nVersion));
nVersion = this->nVersion;
@ -275,8 +266,6 @@ public:
READWRITE(*const_cast<uint32_t*>(&nLockTime));
if (fRead)
UpdateHash();
return nSerSize;
}
bool IsNull() const {
@ -327,16 +316,12 @@ struct CMutableTransaction
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(this->nVersion);
nVersion = this->nVersion;
READWRITE(vin);
READWRITE(vout);
READWRITE(nLockTime);
return nSerSize;
}
/** Compute the hash of this CMutableTransaction. This is computed on the
@ -360,9 +345,8 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
bool fRead = boost::is_same<Operation, CSerActionUnserialize>();
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
bool fRead = ser_action.ForRead();
if (!fRead) {
uint64_t nVal = CompressAmount(txout.nValue);
READWRITE(VARINT(nVal));
@ -373,7 +357,6 @@ public:
}
CScriptCompressor cscript(REF(txout.scriptPubKey));
READWRITE(cscript);
return nSerSize;
}
};
@ -430,10 +413,8 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(vprevout);
return nSerSize;
}
};
@ -465,9 +446,7 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(this->nVersion);
nVersion = this->nVersion;
READWRITE(hashPrevBlock);
@ -475,8 +454,6 @@ public:
READWRITE(nTime);
READWRITE(nBits);
READWRITE(nNonce);
return nSerSize;
}
void SetNull()
@ -526,13 +503,9 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(*(CBlockHeader*)this);
READWRITE(vtx);
return nSerSize;
}
void SetNull()
@ -580,14 +553,10 @@ struct CBlockLocator
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
if (!(nType & SER_GETHASH))
READWRITE(nVersion);
READWRITE(vHave);
return nSerSize;
}
void SetNull()

View file

@ -46,14 +46,12 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(vchCryptedKey);
READWRITE(vchSalt);
READWRITE(nDerivationMethod);
READWRITE(nDeriveIterations);
READWRITE(vchOtherDerivationParameters);
return nSerSize;
}
CMasterKey()

View file

@ -200,11 +200,9 @@ struct CDiskBlockPos
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(VARINT(nFile));
READWRITE(VARINT(nPos));
return nSerSize;
}
CDiskBlockPos() {
@ -235,11 +233,9 @@ struct CDiskTxPos : public CDiskBlockPos
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(*(CDiskBlockPos*)this);
READWRITE(VARINT(nTxOffset));
return nSerSize;
}
CDiskTxPos(const CDiskBlockPos &blockIn, unsigned int nTxOffsetIn) : CDiskBlockPos(blockIn.nFile, blockIn.nPos), nTxOffset(nTxOffsetIn) {
@ -320,10 +316,8 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(vtxundo);
return nSerSize;
}
bool WriteToDisk(CDiskBlockPos &pos, const uint256 &hashBlock);
@ -429,9 +423,8 @@ public:
IMPLEMENT_SERIALIZE;
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>();
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
bool fRead = ser_action.ForRead();
READWRITE(nTransactions);
READWRITE(vHash);
@ -449,8 +442,6 @@ public:
vBytes[p / 8] |= vBits[p] << (p % 8);
READWRITE(vBytes);
}
return nSerSize;
}
// Construct a partial merkle tree from a list of transaction id's, and a mask that selects a subset of them
@ -510,9 +501,7 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(VARINT(nBlocks));
READWRITE(VARINT(nSize));
READWRITE(VARINT(nUndoSize));
@ -520,8 +509,6 @@ public:
READWRITE(VARINT(nHeightLast));
READWRITE(VARINT(nTimeFirst));
READWRITE(VARINT(nTimeLast));
return nSerSize;
}
void SetNull() {
@ -788,9 +775,7 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
if (!(nType & SER_GETHASH))
READWRITE(VARINT(nVersion));
@ -811,8 +796,6 @@ public:
READWRITE(nTime);
READWRITE(nBits);
READWRITE(nNonce);
return nSerSize;
}
uint256 GetBlockHash() const
@ -1014,11 +997,9 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(header);
READWRITE(txn);
return nSerSize;
}
};

View file

@ -91,10 +91,8 @@ class CNetAddr
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(FLATDATA(ip));
return nSerSize;
}
};
@ -155,16 +153,13 @@ class CService : public CNetAddr
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
bool fRead = boost::is_same<Operation, CSerActionUnserialize>();
size_t nSerSize = 0;
CService* pthis = const_cast<CService*>(this);
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
bool fRead = ser_action.ForRead();
READWRITE(FLATDATA(ip));
unsigned short portN = htons(port);
READWRITE(portN);
if (fRead)
pthis->port = ntohs(portN);
return nSerSize;
port = ntohs(portN);
}
};

View file

@ -38,13 +38,11 @@ class CMessageHeader
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(FLATDATA(pchMessageStart));
READWRITE(FLATDATA(pchCommand));
READWRITE(nMessageSize);
READWRITE(nChecksum);
return nSerSize;
}
// TODO: make private (improves encapsulation)
@ -90,12 +88,10 @@ class CAddress : public CService
IMPLEMENT_SERIALIZE;
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>();
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
bool fRead = ser_action.ForRead();
CAddress* pthis = const_cast<CAddress*>(this);
CService* pip = (CService*)pthis;
if (fRead)
pthis->Init();
if (nType & SER_DISK)
@ -104,9 +100,7 @@ class CAddress : public CService
(nVersion >= CADDR_TIME_VERSION && !(nType & SER_GETHASH)))
READWRITE(nTime);
READWRITE(nServices);
READWRITE(*pip);
return nSerSize;
READWRITE(*(CService*)this);
}
// TODO: make private (improves encapsulation)
@ -131,11 +125,9 @@ class CInv
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(type);
READWRITE(hash);
return nSerSize;
}
friend bool operator<(const CInv& a, const CInv& b);

View file

@ -27,9 +27,8 @@ public:
IMPLEMENT_SERIALIZE;
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>();
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
bool fRead = ser_action.ForRead();
RecentRequestEntry* pthis = const_cast<RecentRequestEntry*>(this);
@ -42,9 +41,7 @@ public:
READWRITE(recipient);
if (fRead)
pthis->date = QDateTime::fromTime_t(nDate);
return nSerSize;
date = QDateTime::fromTime_t(nDate);
}
};

View file

@ -62,9 +62,8 @@ public:
IMPLEMENT_SERIALIZE;
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>();
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
bool fRead = ser_action.ForRead();
SendCoinsRecipient* pthis = const_cast<SendCoinsRecipient*>(this);
@ -94,8 +93,6 @@ public:
pthis->paymentRequest.parse(QByteArray::fromRawData(sPaymentRequest.data(), sPaymentRequest.size()));
pthis->authenticatedMerchant = QString::fromStdString(sAuthenticatedMerchant);
}
return nSerSize;
}
};

View file

@ -22,7 +22,6 @@
#include <boost/tuple/tuple.hpp>
#include <boost/type_traits/is_fundamental.hpp>
#include <boost/typeof/typeof.hpp>
class CAutoFile;
class CDataStream;
@ -88,24 +87,25 @@ enum
SER_GETHASH = (1 << 2),
};
#define READWRITE(obj) (nSerSize += ::SerReadWrite(s, (obj), nType, nVersion, ser_action))
#define READWRITE(obj) (::SerReadWrite(s, (obj), nType, nVersion, ser_action))
/* Implement three methods for serializable objects. These are actually wrappers over
* "SerializationOp" template, which implements the body of each class' serialization
* code. Adding "IMPLEMENT_SERIALIZE" in the body of the class causes these wrappers to be
* added as members. */
#define IMPLEMENT_SERIALIZE \
size_t GetSerializeSize(int nType, int nVersion) const { \
ser_streamplaceholder s; \
return NCONST_PTR(this)->SerializationOp(s, CSerActionGetSerializeSize(), nType, nVersion); \
} \
template<typename Stream> \
void Serialize(Stream& s, int nType, int nVersion) const { \
NCONST_PTR(this)->SerializationOp(s, CSerActionSerialize(), nType, nVersion); \
} \
template<typename Stream> \
void Unserialize(Stream& s, int nType, int nVersion) { \
SerializationOp(s, CSerActionUnserialize(), nType, nVersion); \
#define IMPLEMENT_SERIALIZE \
size_t GetSerializeSize(int nType, int nVersion) const { \
CSizeComputer s(nType, nVersion); \
NCONST_PTR(this)->SerializationOp(s, CSerActionSerialize(), nType, nVersion);\
return s.size(); \
} \
template<typename Stream> \
void Serialize(Stream& s, int nType, int nVersion) const { \
NCONST_PTR(this)->SerializationOp(s, CSerActionSerialize(), nType, nVersion);\
} \
template<typename Stream> \
void Unserialize(Stream& s, int nType, int nVersion) { \
SerializationOp(s, CSerActionUnserialize(), nType, nVersion); \
}
@ -809,32 +809,27 @@ void Unserialize(Stream& is, std::set<K, Pred, A>& m, int nType, int nVersion)
//
// Support for IMPLEMENT_SERIALIZE and READWRITE macro
//
class CSerActionGetSerializeSize { };
class CSerActionSerialize { };
class CSerActionUnserialize { };
template<typename Stream, typename T>
inline unsigned int SerReadWrite(Stream& s, const T& obj, int nType, int nVersion, CSerActionGetSerializeSize ser_action)
struct CSerActionSerialize
{
return ::GetSerializeSize(obj, nType, nVersion);
}
bool ForRead() const { return false; }
};
struct CSerActionUnserialize
{
bool ForRead() const { return true; }
};
template<typename Stream, typename T>
inline unsigned int SerReadWrite(Stream& s, const T& obj, int nType, int nVersion, CSerActionSerialize ser_action)
inline void SerReadWrite(Stream& s, const T& obj, int nType, int nVersion, CSerActionSerialize ser_action)
{
::Serialize(s, obj, nType, nVersion);
return 0;
}
template<typename Stream, typename T>
inline unsigned int SerReadWrite(Stream& s, T& obj, int nType, int nVersion, CSerActionUnserialize ser_action)
inline void SerReadWrite(Stream& s, T& obj, int nType, int nVersion, CSerActionUnserialize ser_action)
{
::Unserialize(s, obj, nType, nVersion);
return 0;
}
struct ser_streamplaceholder { };

View file

@ -66,13 +66,11 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
if (!(nType & SER_GETHASH))
READWRITE(nVersion);
READWRITE(nTime);
READWRITE(vchPubKey);
return nSerSize;
}
};
@ -496,16 +494,12 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
nSerSize += SerReadWrite(s, *(CTransaction*)this, nType, nVersion, ser_action);
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(*(CTransaction*)this);
nVersion = this->nVersion;
READWRITE(hashBlock);
READWRITE(vMerkleBranch);
READWRITE(nIndex);
return nSerSize;
}
int SetMerkleBranch(const CBlock* pblock=NULL);
@ -613,9 +607,8 @@ public:
IMPLEMENT_SERIALIZE;
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>();
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
bool fRead = ser_action.ForRead();
CWalletTx* pthis = const_cast<CWalletTx*>(this);
if (fRead)
@ -632,7 +625,7 @@ public:
pthis->mapValue["timesmart"] = strprintf("%u", nTimeSmart);
}
nSerSize += SerReadWrite(s, *(CMerkleTx*)this, nType, nVersion,ser_action);
READWRITE(*(CMerkleTx*)this);
std::vector<CMerkleTx> vUnused; // Used to be vtxPrev
READWRITE(vUnused);
READWRITE(mapValue);
@ -651,13 +644,11 @@ public:
pthis->nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(pthis->mapValue["timesmart"]) : 0;
}
pthis->mapValue.erase("fromaccount");
pthis->mapValue.erase("version");
pthis->mapValue.erase("spent");
pthis->mapValue.erase("n");
pthis->mapValue.erase("timesmart");
return nSerSize;
mapValue.erase("fromaccount");
mapValue.erase("version");
mapValue.erase("spent");
mapValue.erase("n");
mapValue.erase("timesmart");
}
// make sure balances are recalculated
@ -907,15 +898,13 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
if (!(nType & SER_GETHASH))
READWRITE(nVersion);
READWRITE(vchPrivKey);
READWRITE(nTimeCreated);
READWRITE(nTimeExpires);
READWRITE(LIMITED_STRING(strComment, 65536));
return nSerSize;
}
};
@ -945,12 +934,10 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
if (!(nType & SER_GETHASH))
READWRITE(nVersion);
READWRITE(vchPubKey);
return nSerSize;
}
};
@ -990,9 +977,8 @@ public:
IMPLEMENT_SERIALIZE;
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>();
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
bool fRead = ser_action.ForRead();
CAccountingEntry& me = *const_cast<CAccountingEntry*>(this);
if (!(nType & SER_GETHASH))
@ -1033,9 +1019,7 @@ public:
if (std::string::npos != nSepPos)
me.strComment.erase(nSepPos);
me.mapValue.erase("n");
return nSerSize;
mapValue.erase("n");
}
private:

View file

@ -57,12 +57,10 @@ public:
IMPLEMENT_SERIALIZE;
template <typename Stream, typename Operation>
inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
size_t nSerSize = 0;
inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
READWRITE(this->nVersion);
nVersion = this->nVersion;
READWRITE(nCreateTime);
return nSerSize;
}
void SetNull()