@@ -215,7 +215,6 @@ class CBlockIndex
215215 // char vector holding the stake modifier bytes. It is empty for PoW blocks.
216216 // Modifier V1 is 64 bit while modifier V2 is 256 bit.
217217 std::vector<unsigned char > vStakeModifier{};
218- int64_t nMoneySupply{0 };
219218 unsigned int nFlags{0 };
220219
221220 // ! block header
@@ -275,7 +274,7 @@ class CBlockIndex
275274
276275// New serialization introduced with 4.0.99
277276static const int DBI_OLD_SER_VERSION = 4009900 ;
278- static const int DBI_SER_VERSION_NO_ZC = 4009902 ; // removes mapZerocoinSupply
277+ static const int DBI_SER_VERSION_NO_ZC = 4009902 ; // removes mapZerocoinSupply, nMoneySupply
279278
280279class CDiskBlockIndex : public CBlockIndex
281280{
@@ -310,8 +309,23 @@ class CDiskBlockIndex : public CBlockIndex
310309 if (nStatus & BLOCK_HAVE_UNDO)
311310 READWRITE (VARINT (nUndoPos));
312311
313- if (nSerVersion > DBI_OLD_SER_VERSION) {
314- // Serialization with CLIENT_VERSION > 4009900
312+ if (nSerVersion >= DBI_SER_VERSION_NO_ZC) {
313+ // Serialization with CLIENT_VERSION = 4009902+
314+ READWRITE (nFlags);
315+ READWRITE (this ->nVersion );
316+ READWRITE (vStakeModifier);
317+ READWRITE (hashPrev);
318+ READWRITE (hashMerkleRoot);
319+ READWRITE (nTime);
320+ READWRITE (nBits);
321+ READWRITE (nNonce);
322+ if (this ->nVersion > 3 && this ->nVersion < 7 )
323+ READWRITE (nAccumulatorCheckpoint);
324+
325+ } else if (nSerVersion > DBI_OLD_SER_VERSION) {
326+ // Serialization with CLIENT_VERSION = 4009901
327+ std::map<libzerocoin::CoinDenomination, int64_t > mapZerocoinSupply;
328+ int64_t nMoneySupply = 0 ;
315329 READWRITE (nMoneySupply);
316330 READWRITE (nFlags);
317331 READWRITE (this ->nVersion );
@@ -322,18 +336,15 @@ class CDiskBlockIndex : public CBlockIndex
322336 READWRITE (nBits);
323337 READWRITE (nNonce);
324338 if (this ->nVersion > 3 ) {
325- // zc supply removed in 4.0.99.2
326- if (nSerVersion < DBI_SER_VERSION_NO_ZC) {
327- std::map<libzerocoin::CoinDenomination, int64_t > mapZerocoinSupply;
328- READWRITE (mapZerocoinSupply);
329- }
339+ READWRITE (mapZerocoinSupply);
330340 if (this ->nVersion < 7 ) READWRITE (nAccumulatorCheckpoint);
331341 }
332342
333343 } else {
334- // Serialization with CLIENT_VERSION < = 4009900
344+ // Serialization with CLIENT_VERSION = 4009900-
335345 int64_t nMint = 0 ;
336- uint256 hashNext;
346+ uint256 hashNext{};
347+ int64_t nMoneySupply = 0 ;
337348 READWRITE (nMint);
338349 READWRITE (nMoneySupply);
339350 READWRITE (nFlags);
@@ -410,6 +421,7 @@ class CLegacyBlockIndex : public CBlockIndex
410421 COutPoint prevoutStake{};
411422 unsigned int nStakeTime = 0 ;
412423 std::vector<libzerocoin::CoinDenomination> vMintDenominationsInBlock;
424+ int64_t nMoneySupply = 0 ;
413425
414426
415427 ADD_SERIALIZE_METHODS;
@@ -420,6 +432,11 @@ class CLegacyBlockIndex : public CBlockIndex
420432 if (!(nType & SER_GETHASH))
421433 READWRITE (VARINT (nSerVersion));
422434
435+ if (nSerVersion >= DBI_SER_VERSION_NO_ZC) {
436+ // no extra serialized field
437+ return ;
438+ }
439+
423440 READWRITE (VARINT (nHeight));
424441 READWRITE (VARINT (nStatus));
425442 READWRITE (VARINT (nTx));
@@ -431,7 +448,7 @@ class CLegacyBlockIndex : public CBlockIndex
431448 READWRITE (VARINT (nUndoPos));
432449
433450 if (nSerVersion > DBI_OLD_SER_VERSION) {
434- // Serialization with CLIENT_VERSION > 4009900
451+ // Serialization with CLIENT_VERSION = 4009901
435452 READWRITE (nMoneySupply);
436453 READWRITE (nFlags);
437454 READWRITE (this ->nVersion );
@@ -442,15 +459,12 @@ class CLegacyBlockIndex : public CBlockIndex
442459 READWRITE (nBits);
443460 READWRITE (nNonce);
444461 if (this ->nVersion > 3 ) {
445- // zc supply removed in 4.0.99.2
446- if (nSerVersion < DBI_SER_VERSION_NO_ZC) {
447- READWRITE (mapZerocoinSupply);
448- }
462+ READWRITE (mapZerocoinSupply);
449463 if (this ->nVersion < 7 ) READWRITE (nAccumulatorCheckpoint);
450464 }
451465
452466 } else {
453- // Serialization with CLIENT_VERSION < = 4009900
467+ // Serialization with CLIENT_VERSION = 4009900-
454468 READWRITE (nMint);
455469 READWRITE (nMoneySupply);
456470 READWRITE (nFlags);
0 commit comments