aboutsummaryrefslogtreecommitdiff
path: root/src/main.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-08-21 00:49:32 +0200
committerKamil Domanski <kdomanski@kdemail.net>2014-08-31 02:18:42 +0200
commit31e9a8384a77947f6777d035992f4734618ed206 (patch)
tree9a055fbae630bad4b7982a5aae1294a9579382cb /src/main.h
parent84881f8c472cc67dc757686eb7dc3b495b13cab8 (diff)
downloadbitcoin-31e9a8384a77947f6777d035992f4734618ed206.tar.xz
Use CSizeComputer to avoid counting sizes in SerializationOp
Diffstat (limited to 'src/main.h')
-rw-r--r--src/main.h35
1 files changed, 8 insertions, 27 deletions
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 <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;
}
};