@@ -373,6 +373,9 @@ std::list<libzerocoin::CoinDenomination> ZerocoinSpendListFromBlock(const CBlock
373
373
374
374
bool UpdateXIONSupply (const CBlock& block, CBlockIndex* pindex, bool fJustCheck )
375
375
{
376
+ // Only update xION supply when zerocoin mint amount can change
377
+ if (pindex->nVersion <= 3 || pindex->nVersion > 11 ) return true ;
378
+
376
379
std::list<CZerocoinMint> listMints;
377
380
bool fFilterInvalid = false ;// pindex->nHeight >= Params().Zerocoin_Block_RecalculateAccumulators();
378
381
BlockToZerocoinMintList (block, listMints, fFilterInvalid );
@@ -381,7 +384,8 @@ bool UpdateXIONSupply(const CBlock& block, CBlockIndex* pindex, bool fJustCheck)
381
384
// Initialize zerocoin supply to the supply from previous block
382
385
if (pindex->pprev && pindex->pprev ->GetBlockHeader ().nVersion > 3 ) {
383
386
for (auto & denom : libzerocoin::zerocoinDenomList) {
384
- pindex->mapZerocoinSupply .at (denom) = pindex->pprev ->GetZcMints (denom);
387
+ uint16_t nMints = pindex->pprev ->GetZcMints (denom);
388
+ if (nMints != 0 ) pindex->mapZerocoinSupply [denom] = nMints;
385
389
}
386
390
}
387
391
@@ -393,7 +397,7 @@ bool UpdateXIONSupply(const CBlock& block, CBlockIndex* pindex, bool fJustCheck)
393
397
for (auto & m : listMints) {
394
398
libzerocoin::CoinDenomination denom = m.GetDenomination ();
395
399
pindex->vMintDenominationsInBlock .push_back (m.GetDenomination ());
396
- pindex->mapZerocoinSupply . at (denom)++ ;
400
+ pindex->mapZerocoinSupply [denom] = pindex-> GetZcMints (denom) + 1 ;
397
401
398
402
/*
399
403
//Remove any of our own mints from the mintpool
@@ -420,17 +424,20 @@ bool UpdateXIONSupply(const CBlock& block, CBlockIndex* pindex, bool fJustCheck)
420
424
}
421
425
422
426
for (auto & denom : listSpends) {
423
- pindex->mapZerocoinSupply .at (denom)--;
424
- nAmountZerocoinSpent += libzerocoin::ZerocoinDenominationToAmount (denom);
427
+ uint16_t nMints = pindex->GetZcMints (denom);
425
428
426
429
// zerocoin failsafe
427
- if (pindex-> GetZcMints (denom) < 0 )
430
+ if (nMints == 0 )
428
431
return error (" Block contains zerocoins that spend more than are in the available supply to spend" );
432
+
433
+ pindex->mapZerocoinSupply [denom] = nMints - 1 ;
434
+ nAmountZerocoinSpent += libzerocoin::ZerocoinDenominationToAmount (denom);
435
+
429
436
}
430
437
}
431
438
432
439
for (auto & denom : libzerocoin::zerocoinDenomList)
433
- LogPrint (BCLog::ZEROCOIN, " %s coins for denomination %d pubcoin %s\n " , __func__, denom, pindex->mapZerocoinSupply . at (denom));
440
+ LogPrint (BCLog::ZEROCOIN, " %s coins for denomination %d pubcoin %s\n " , __func__, denom, pindex->GetZcMints (denom));
434
441
435
442
return true ;
436
443
}
0 commit comments