aboutsummaryrefslogtreecommitdiff
path: root/src/wallet.h
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2014-09-01 21:00:32 +0200
committerPieter Wuille <pieter.wuille@gmail.com>2014-09-01 21:23:01 +0200
commit2e731f24b5a5c894e013a6d752f1cd409303e916 (patch)
tree94ba6f1e3ab9ecb5ac1696b48b1aabc859aa8365 /src/wallet.h
parentf6a81050372810d8eebc15523bde28e91d045314 (diff)
parent31e9a8384a77947f6777d035992f4734618ed206 (diff)
Merge pull request #4737
31e9a83 Use CSizeComputer to avoid counting sizes in SerializationOp (Pieter Wuille) 84881f8 rework overhauled serialization methods to non-static (Kamil Domanski) 5d96b4a remove fields of ser_streamplaceholder (Kamil Domanski) 3d796f8 overhaul serialization code (Kamil Domanski)
Diffstat (limited to 'src/wallet.h')
-rw-r--r--src/wallet.h69
1 files changed, 41 insertions, 28 deletions
diff --git a/src/wallet.h b/src/wallet.h
index 41b4b1917c..cea61afed3 100644
--- a/src/wallet.h
+++ b/src/wallet.h
@@ -64,13 +64,15 @@ public:
CKeyPool();
CKeyPool(const CPubKey& vchPubKeyIn);
- IMPLEMENT_SERIALIZE
- (
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
if (!(nType & SER_GETHASH))
READWRITE(nVersion);
READWRITE(nTime);
READWRITE(vchPubKey);
- )
+ }
};
/** Address book data */
@@ -490,16 +492,16 @@ public:
fMerkleVerified = false;
}
+ IMPLEMENT_SERIALIZE;
- IMPLEMENT_SERIALIZE
- (
- nSerSize += SerReadWrite(s, *(CTransaction*)this, nType, nVersion, ser_action);
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
+ READWRITE(*(CTransaction*)this);
nVersion = this->nVersion;
READWRITE(hashBlock);
READWRITE(vMerkleBranch);
READWRITE(nIndex);
- )
-
+ }
int SetMerkleBranch(const CBlock* pblock=NULL);
@@ -514,7 +516,6 @@ public:
bool AcceptToMemoryPool(bool fLimitFree=true, bool fRejectInsaneFee=true);
};
-
/** A transaction with a bunch of additional info that only the owner cares about.
* It includes any unrecorded transactions needed to link it back to the block chain.
*/
@@ -604,8 +605,12 @@ public:
nOrderPos = -1;
}
- IMPLEMENT_SERIALIZE
- (
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ 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)
pthis->Init(NULL);
@@ -621,7 +626,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);
@@ -640,12 +645,12 @@ 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");
- )
+ mapValue.erase("fromaccount");
+ mapValue.erase("version");
+ mapValue.erase("spent");
+ mapValue.erase("n");
+ mapValue.erase("timesmart");
+ }
// make sure balances are recalculated
void MarkDirty()
@@ -891,15 +896,17 @@ public:
CWalletKey(int64_t nExpires=0);
- IMPLEMENT_SERIALIZE
- (
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ 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));
- )
+ }
};
@@ -925,12 +932,14 @@ public:
vchPubKey = CPubKey();
}
- IMPLEMENT_SERIALIZE
- (
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ inline void SerializationOp(Stream& s, Operation ser_action, int nType, int nVersion) {
if (!(nType & SER_GETHASH))
READWRITE(nVersion);
READWRITE(vchPubKey);
- )
+ }
};
@@ -966,8 +975,12 @@ public:
nEntryNo = 0;
}
- IMPLEMENT_SERIALIZE
- (
+ IMPLEMENT_SERIALIZE;
+
+ template <typename Stream, typename Operation>
+ 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))
READWRITE(nVersion);
@@ -1007,8 +1020,8 @@ public:
if (std::string::npos != nSepPos)
me.strComment.erase(nSepPos);
- me.mapValue.erase("n");
- )
+ mapValue.erase("n");
+ }
private:
std::vector<char> _ssExtra;