aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.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/wallet.h
parent84881f8c472cc67dc757686eb7dc3b495b13cab8 (diff)
Use CSizeComputer to avoid counting sizes in SerializationOp
Diffstat (limited to 'src/wallet.h')
-rw-r--r--src/wallet.h48
1 files changed, 16 insertions, 32 deletions
diff --git a/src/wallet.h b/src/wallet.h
index d30a28218f..aa811ee584 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -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: