diff options
| author | Pieter Wuille <[email protected]> | 2018-03-09 17:04:31 -0800 |
|---|---|---|
| committer | Pieter Wuille <[email protected]> | 2018-03-09 17:04:31 -0800 |
| commit | 029ecac1bc361736a9b6c8fe5652558ca383b4b9 (patch) | |
| tree | 87d11ede82b36d5cdbdb92ec14891a383895a31d /src | |
| parent | Merge #12607: depends: Remove ccache (diff) | |
| download | discoin-029ecac1bc361736a9b6c8fe5652558ca383b4b9.tar.xz discoin-029ecac1bc361736a9b6c8fe5652558ca383b4b9.zip | |
Split up and sanitize CWalletTx serialization
Diffstat (limited to 'src')
| -rw-r--r-- | src/wallet/wallet.h | 50 |
1 files changed, 22 insertions, 28 deletions
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 3e2d1794d..eabd1c1c3 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -390,42 +390,36 @@ public: nOrderPos = -1; } - ADD_SERIALIZE_METHODS; - - template <typename Stream, typename Operation> - inline void SerializationOp(Stream& s, Operation ser_action) { - if (ser_action.ForRead()) - Init(nullptr); + template<typename Stream> + void Serialize(Stream& s) const + { char fSpent = false; + mapValue_t mapValueCopy = mapValue; - if (!ser_action.ForRead()) - { - mapValue["fromaccount"] = strFromAccount; - - WriteOrderPos(nOrderPos, mapValue); - - if (nTimeSmart) - mapValue["timesmart"] = strprintf("%u", nTimeSmart); + mapValueCopy["fromaccount"] = strFromAccount; + WriteOrderPos(nOrderPos, mapValueCopy); + if (nTimeSmart) { + mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart); } - READWRITE(*static_cast<CMerkleTx*>(this)); + s << *static_cast<const CMerkleTx*>(this); std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev - READWRITE(vUnused); - READWRITE(mapValue); - READWRITE(vOrderForm); - READWRITE(fTimeReceivedIsTxTime); - READWRITE(nTimeReceived); - READWRITE(fFromMe); - READWRITE(fSpent); + s << vUnused << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime << nTimeReceived << fFromMe << fSpent; + } - if (ser_action.ForRead()) - { - strFromAccount = mapValue["fromaccount"]; + template<typename Stream> + void Unserialize(Stream& s) + { + Init(nullptr); + char fSpent; - ReadOrderPos(nOrderPos, mapValue); + s >> *static_cast<CMerkleTx*>(this); + std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev + s >> vUnused >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> nTimeReceived >> fFromMe >> fSpent; - nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(mapValue["timesmart"]) : 0; - } + strFromAccount = std::move(mapValue["fromaccount"]); + ReadOrderPos(nOrderPos, mapValue); + nTimeSmart = mapValue.count("timesmart") ? (unsigned int)atoi64(mapValue["timesmart"]) : 0; mapValue.erase("fromaccount"); mapValue.erase("spent"); |