From 31e9a8384a77947f6777d035992f4734618ed206 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Thu, 21 Aug 2014 00:49:32 +0200 Subject: Use CSizeComputer to avoid counting sizes in SerializationOp --- src/main.h | 35 ++++++++--------------------------- 1 file changed, 8 insertions(+), 27 deletions(-) (limited to 'src/main.h') diff --git a/src/main.h b/src/main.h index 8a5fa0e7e0..cea8a649e3 100644 --- a/src/main.h +++ b/src/main.h @@ -200,11 +200,9 @@ struct CDiskBlockPos IMPLEMENT_SERIALIZE; template - 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 - 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 - 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 - inline size_t SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) { - size_t nSerSize = 0; - bool fRead = boost::is_same(); + 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 - 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 - 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 - 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; } }; -- cgit v1.2.3