Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.h
Show First 20 Lines • Show All 345 Lines • ▼ Show 20 Lines | void Init(const CWallet *pwalletIn) { | ||||
nWatchDebitCached = Amount::zero(); | nWatchDebitCached = Amount::zero(); | ||||
nWatchCreditCached = Amount::zero(); | nWatchCreditCached = Amount::zero(); | ||||
nAvailableWatchCreditCached = Amount::zero(); | nAvailableWatchCreditCached = Amount::zero(); | ||||
nImmatureWatchCreditCached = Amount::zero(); | nImmatureWatchCreditCached = Amount::zero(); | ||||
nChangeCached = Amount::zero(); | nChangeCached = Amount::zero(); | ||||
nOrderPos = -1; | nOrderPos = -1; | ||||
} | } | ||||
ADD_SERIALIZE_METHODS; | template <typename Stream> void Serialize(Stream &s) const { | ||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
if (ser_action.ForRead()) { | |||||
Init(nullptr); | |||||
} | |||||
char fSpent = false; | char fSpent = false; | ||||
mapValue_t mapValueCopy = mapValue; | |||||
if (!ser_action.ForRead()) { | mapValueCopy["fromaccount"] = strFromAccount; | ||||
mapValue["fromaccount"] = strFromAccount; | WriteOrderPos(nOrderPos, mapValueCopy); | ||||
WriteOrderPos(nOrderPos, mapValue); | |||||
if (nTimeSmart) { | if (nTimeSmart) { | ||||
mapValue["timesmart"] = strprintf("%u", nTimeSmart); | mapValueCopy["timesmart"] = strprintf("%u", nTimeSmart); | ||||
} | } | ||||
s << *static_cast<const CMerkleTx *>(this); | |||||
std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev | |||||
s << vUnused << mapValueCopy << vOrderForm << fTimeReceivedIsTxTime | |||||
<< nTimeReceived << fFromMe << fSpent; | |||||
} | } | ||||
READWRITE(*static_cast<CMerkleTx *>(this)); | template <typename Stream> void Unserialize(Stream &s) { | ||||
//!< Used to be vtxPrev | Init(nullptr); | ||||
std::vector<CMerkleTx> vUnused; | char fSpent; | ||||
READWRITE(vUnused); | |||||
READWRITE(mapValue); | |||||
READWRITE(vOrderForm); | |||||
READWRITE(fTimeReceivedIsTxTime); | |||||
READWRITE(nTimeReceived); | |||||
READWRITE(fFromMe); | |||||
READWRITE(fSpent); | |||||
if (ser_action.ForRead()) { | s >> *static_cast<CMerkleTx *>(this); | ||||
strFromAccount = mapValue["fromaccount"]; | std::vector<CMerkleTx> vUnused; //!< Used to be vtxPrev | ||||
s >> vUnused >> mapValue >> vOrderForm >> fTimeReceivedIsTxTime >> | |||||
nTimeReceived >> fFromMe >> fSpent; | |||||
strFromAccount = std::move(mapValue["fromaccount"]); | |||||
ReadOrderPos(nOrderPos, mapValue); | ReadOrderPos(nOrderPos, mapValue); | ||||
nTimeSmart = mapValue.count("timesmart") | nTimeSmart = mapValue.count("timesmart") | ||||
? (unsigned int)atoi64(mapValue["timesmart"]) | ? (unsigned int)atoi64(mapValue["timesmart"]) | ||||
: 0; | : 0; | ||||
} | |||||
mapValue.erase("fromaccount"); | mapValue.erase("fromaccount"); | ||||
mapValue.erase("version"); | mapValue.erase("version"); | ||||
mapValue.erase("spent"); | mapValue.erase("spent"); | ||||
mapValue.erase("n"); | mapValue.erase("n"); | ||||
mapValue.erase("timesmart"); | mapValue.erase("timesmart"); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 165 Lines • ▼ Show 20 Lines | void SetNull() { | ||||
nTime = 0; | nTime = 0; | ||||
strAccount.clear(); | strAccount.clear(); | ||||
strOtherAccount.clear(); | strOtherAccount.clear(); | ||||
strComment.clear(); | strComment.clear(); | ||||
nOrderPos = -1; | nOrderPos = -1; | ||||
nEntryNo = 0; | nEntryNo = 0; | ||||
} | } | ||||
ADD_SERIALIZE_METHODS; | template <typename Stream> void Serialize(Stream &s) const { | ||||
template <typename Stream, typename Operation> | |||||
inline void SerializationOp(Stream &s, Operation ser_action) { | |||||
int nVersion = s.GetVersion(); | int nVersion = s.GetVersion(); | ||||
if (!(s.GetType() & SER_GETHASH)) READWRITE(nVersion); | if (!(s.GetType() & SER_GETHASH)) { | ||||
s << nVersion; | |||||
} | |||||
//! Note: strAccount is serialized as part of the key, not here. | //! Note: strAccount is serialized as part of the key, not here. | ||||
READWRITE(nCreditDebit); | s << nCreditDebit << nTime << strOtherAccount; | ||||
READWRITE(nTime); | |||||
READWRITE(LIMITED_STRING(strOtherAccount, 65536)); | |||||
if (!ser_action.ForRead()) { | mapValue_t mapValueCopy = mapValue; | ||||
WriteOrderPos(nOrderPos, mapValue); | WriteOrderPos(nOrderPos, mapValueCopy); | ||||
if (!(mapValue.empty() && _ssExtra.empty())) { | std::string strCommentCopy = strComment; | ||||
if (!mapValueCopy.empty() || !_ssExtra.empty()) { | |||||
CDataStream ss(s.GetType(), s.GetVersion()); | CDataStream ss(s.GetType(), s.GetVersion()); | ||||
ss.insert(ss.begin(), '\0'); | ss.insert(ss.begin(), '\0'); | ||||
ss << mapValue; | ss << mapValueCopy; | ||||
ss.insert(ss.end(), _ssExtra.begin(), _ssExtra.end()); | ss.insert(ss.end(), _ssExtra.begin(), _ssExtra.end()); | ||||
strComment.append(ss.str()); | strCommentCopy.append(ss.str()); | ||||
} | } | ||||
s << strCommentCopy; | |||||
} | } | ||||
READWRITE(LIMITED_STRING(strComment, 65536)); | template <typename Stream> void Unserialize(Stream &s) { | ||||
int nVersion = s.GetVersion(); | |||||
if (!(s.GetType() & SER_GETHASH)) { | |||||
s >> nVersion; | |||||
} | |||||
//! Note: strAccount is serialized as part of the key, not here. | |||||
s >> nCreditDebit >> nTime >> LIMITED_STRING(strOtherAccount, 65536) >> | |||||
LIMITED_STRING(strComment, 65536); | |||||
size_t nSepPos = strComment.find("\0", 0, 1); | size_t nSepPos = strComment.find("\0", 0, 1); | ||||
if (ser_action.ForRead()) { | |||||
mapValue.clear(); | mapValue.clear(); | ||||
if (std::string::npos != nSepPos) { | if (std::string::npos != nSepPos) { | ||||
CDataStream ss( | CDataStream ss(std::vector<char>(strComment.begin() + nSepPos + 1, | ||||
std::vector<char>(strComment.begin() + nSepPos + 1, | |||||
strComment.end()), | strComment.end()), | ||||
s.GetType(), s.GetVersion()); | s.GetType(), s.GetVersion()); | ||||
ss >> mapValue; | ss >> mapValue; | ||||
_ssExtra = std::vector<char>(ss.begin(), ss.end()); | _ssExtra = std::vector<char>(ss.begin(), ss.end()); | ||||
} | } | ||||
ReadOrderPos(nOrderPos, mapValue); | ReadOrderPos(nOrderPos, mapValue); | ||||
if (std::string::npos != nSepPos) { | |||||
strComment.erase(nSepPos); | |||||
} | } | ||||
if (std::string::npos != nSepPos) strComment.erase(nSepPos); | |||||
mapValue.erase("n"); | mapValue.erase("n"); | ||||
} | } | ||||
private: | private: | ||||
std::vector<char> _ssExtra; | std::vector<char> _ssExtra; | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 659 Lines • Show Last 20 Lines |