@@ -390,17 +390,14 @@ bool GetAccumulatorValue(int& nHeight, const libzerocoin::CoinDenomination denom
390390 if (nHeight > chainActive.Height ())
391391 return error (" %s: height %d is more than active chain height" , __func__, nHeight);
392392
393- // Use old db if proto not update yet
393+ // Every situation except for about 20 blocks should use this method
394394 uint256 nCheckpointBeforeMint = chainActive[nHeight]->nAccumulatorCheckpoint ;
395- if (chainActive. Height () < Params ().Zerocoin_Block_V2_Start ())
395+ if (nHeight > Params ().Zerocoin_Block_V2_Start () + 20 )
396396 return GetAccumulatorValueFromDB (nCheckpointBeforeMint, denom, bnAccValue);
397397
398398 int nHeightCheckpoint = 0 ;
399399 AccumulatorCheckpoints::Checkpoint checkpoint = AccumulatorCheckpoints::GetClosestCheckpoint (nHeight, nHeightCheckpoint);
400- if (nHeightCheckpoint < 0 )
401- return error (" %s: failed to load hard-checkpoint for block %s" , __func__, nHeight);
402-
403- if (nHeight < nHeightCheckpoint) {
400+ if (nHeightCheckpoint < 0 ) {
404401 // Start at the first zerocoin
405402 libzerocoin::Accumulator accumulator (Params ().Zerocoin_Params (false ), denom);
406403 bnAccValue = accumulator.getValue ();
@@ -447,16 +444,6 @@ bool GenerateAccumulatorWitness(const PublicCoin &coin, Accumulator& accumulator
447444 // the height to start accumulating coins to add to witness
448445 int nAccStartHeight = nHeightMintAdded - (nHeightMintAdded % 10 );
449446
450- // If the checkpoint is from the recalculated checkpoint period, then adjust it
451- int nHeight_LastGoodCheckpoint = Params ().Zerocoin_Block_LastGoodCheckpoint ();
452- int nHeight_Recalculate = Params ().Zerocoin_Block_RecalculateAccumulators ();
453- CBlockIndex* pindex = chainActive[nHeightMintAdded];
454- if (pindex->nHeight < nHeight_Recalculate - 10 && pindex->nHeight > nHeight_LastGoodCheckpoint) {
455- // The checkpoint before the mint will be the last good checkpoint
456- nHeightCheckpoint = nHeight_LastGoodCheckpoint;
457- nAccStartHeight = nHeight_LastGoodCheckpoint - 10 ;
458- }
459-
460447 // Get the accumulator that is right before the cluster of blocks containing our mint was added to the accumulator
461448 CBigNum bnAccValue = 0 ;
462449 if (GetAccumulatorValue (nHeightCheckpoint, coin.getDenomination (), bnAccValue)) {
@@ -465,7 +452,7 @@ bool GenerateAccumulatorWitness(const PublicCoin &coin, Accumulator& accumulator
465452 }
466453
467454 // add the pubcoins from the blockchain up to the next checksum starting from the block
468- pindex = chainActive[nHeightCheckpoint - 10 ];
455+ CBlockIndex* pindex = chainActive[nHeightCheckpoint - 10 ];
469456 int nChainHeight = chainActive.Height ();
470457 int nHeightStop = nChainHeight % 10 ;
471458 nHeightStop = nChainHeight - nHeightStop - 20 ; // at least two checkpoints deep
0 commit comments