@@ -53,6 +53,8 @@ extern int nCompleteTXLocks;
5353class CInstantSend
5454{
5555private:
56+ static const std::string SERIALIZATION_VERSION_STRING;
57+
5658 // Keep track of current block height
5759 int nCachedBlockHeight;
5860
@@ -91,7 +93,37 @@ class CInstantSend
9193 bool IsInstantSendReadyToLock (const uint256 &txHash);
9294
9395public:
94- CCriticalSection cs_instantsend;
96+ mutable CCriticalSection cs_instantsend;
97+
98+ ADD_SERIALIZE_METHODS;
99+
100+ template <typename Stream, typename Operation>
101+ inline void SerializationOp (Stream& s, Operation ser_action) {
102+ std::string strVersion;
103+ if (ser_action.ForRead ()) {
104+ READWRITE (strVersion);
105+ }
106+ else {
107+ strVersion = SERIALIZATION_VERSION_STRING;
108+ READWRITE (strVersion);
109+ }
110+
111+ READWRITE (mapLockRequestAccepted);
112+ READWRITE (mapLockRequestRejected);
113+ READWRITE (mapTxLockVotes);
114+ READWRITE (mapTxLockVotesOrphan);
115+ READWRITE (mapTxLockCandidates);
116+ READWRITE (mapVotedOutpoints);
117+ READWRITE (mapLockedOutpoints);
118+ READWRITE (mapMasternodeOrphanVotes);
119+ READWRITE (nCachedBlockHeight);
120+
121+ if (ser_action.ForRead () && (strVersion != SERIALIZATION_VERSION_STRING)) {
122+ Clear ();
123+ }
124+ }
125+
126+ void Clear ();
95127
96128 void ProcessMessage (CNode* pfrom, const std::string& strCommand, CDataStream& vRecv, CConnman& connman);
97129
@@ -126,7 +158,7 @@ class CInstantSend
126158 void UpdatedBlockTip (const CBlockIndex *pindex);
127159 void SyncTransaction (const CTransaction& tx, const CBlockIndex *pindex, int posInBlock);
128160
129- std::string ToString ();
161+ std::string ToString () const ;
130162};
131163
132164/* *
@@ -264,13 +296,24 @@ class COutPointLock
264296 static const int SIGNATURES_REQUIRED = 6 ;
265297 static const int SIGNATURES_TOTAL = 10 ;
266298
299+ COutPointLock () {}
300+
267301 COutPointLock (const COutPoint& outpointIn) :
268302 outpoint (outpointIn),
269303 mapMasternodeVotes ()
270304 {}
271305
272306 COutPoint GetOutpoint () const { return outpoint; }
273307
308+ ADD_SERIALIZE_METHODS;
309+
310+ template <typename Stream, typename Operation>
311+ inline void SerializationOp (Stream& s, Operation ser_action) {
312+ READWRITE (outpoint);
313+ READWRITE (mapMasternodeVotes);
314+ READWRITE (fAttacked );
315+ }
316+
274317 bool AddVote (const CTxLockVote& vote);
275318 std::vector<CTxLockVote> GetVotes () const ;
276319 bool HasMasternodeVoted (const COutPoint& outpointMasternodeIn) const ;
@@ -291,6 +334,11 @@ class CTxLockCandidate
291334 int64_t nTimeCreated;
292335
293336public:
337+ CTxLockCandidate () :
338+ nConfirmedHeight (-1 ),
339+ nTimeCreated (GetTime())
340+ {}
341+
294342 CTxLockCandidate (const CTxLockRequest& txLockRequestIn) :
295343 nConfirmedHeight (-1 ),
296344 nTimeCreated (GetTime()),
@@ -301,6 +349,16 @@ class CTxLockCandidate
301349 CTxLockRequest txLockRequest;
302350 std::map<COutPoint, COutPointLock> mapOutPointLocks;
303351
352+ ADD_SERIALIZE_METHODS;
353+
354+ template <typename Stream, typename Operation>
355+ inline void SerializationOp (Stream& s, Operation ser_action) {
356+ READWRITE (txLockRequest);
357+ READWRITE (mapOutPointLocks);
358+ READWRITE (nTimeCreated);
359+ READWRITE (nConfirmedHeight);
360+ }
361+
304362 uint256 GetHash () const { return txLockRequest.GetHash (); }
305363
306364 void AddOutPointLock (const COutPoint& outpoint);
0 commit comments