aboutsummaryrefslogtreecommitdiff
path: root/src/core.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/core.h
parent84881f8c472cc67dc757686eb7dc3b495b13cab8 (diff)
Use CSizeComputer to avoid counting sizes in SerializationOp
Diffstat (limited to 'src/core.h')
-rw-r--r--src/core.h57
1 files changed, 13 insertions, 44 deletions
diff --git a/src/core.h b/src/core.h
index e56be1a4ec..486782e5b7 100644
--- a/src/core.h
+++ b/src/core.h
@@ -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()