@@ -75,6 +75,7 @@ bool fReindex = false;
7575bool fTxIndex = true ;
7676bool fIsBareMultisigStd = true ;
7777bool fCheckBlockIndex = false ;
78+ bool fVerifyingBlocks = false ;
7879unsigned int nCoinCacheSize = 5000 ;
7980bool fAlerts = DEFAULT_ALERTS;
8081
@@ -2625,14 +2626,15 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
26252626 if (tx.ContainsZerocoins ()) {
26262627 if (tx.IsZerocoinSpend ()) {
26272628 // erase all zerocoinspends in this transaction
2628- for (const CTxIn txin : tx.vin ){
2629+ for (const CTxIn txin : tx.vin ) {
26292630 if (txin.scriptSig .IsZerocoinSpend ()) {
26302631 CoinSpend spend = TxInToZerocoinSpend (txin);
2631- if (!CAccumulators::getInstance ().EraseCoinSpend (spend.getCoinSerialNumber ()))
2632+ if (!CAccumulators::getInstance ().EraseCoinSpend (spend.getCoinSerialNumber ()))
26322633 return error (" failed to erase spent zerocoin in block" );
26332634 }
26342635 }
2635- } else if (tx.IsZerocoinMint ()) {
2636+ }
2637+ if (tx.IsZerocoinMint ()) {
26362638 // erase all zerocoinmints in this transaction
26372639 for (const CTxOut txout : tx.vout ) {
26382640 if (txout.scriptPubKey .empty () || !txout.scriptPubKey .IsZerocoinMint ())
@@ -2705,11 +2707,13 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
27052707 // move best block pointer to prevout block
27062708 view.SetBestBlock (pindex->pprev ->GetBlockHash ());
27072709
2708- // if block is an accumulator checkpoint block, remove checkpoint and checksums from db
2709- uint256 nCheckpoint = pindex->nAccumulatorCheckpoint ;
2710- if (nCheckpoint != pindex->pprev ->nAccumulatorCheckpoint ) {
2711- if (!CAccumulators::getInstance ().EraseAccumulatorValues (nCheckpoint, pindex->pprev ->nAccumulatorCheckpoint ))
2712- return error (" DisconnectBlock(): failed to erase checkpoint" );
2710+ if (!fVerifyingBlocks ) {
2711+ // if block is an accumulator checkpoint block, remove checkpoint and checksums from db
2712+ uint256 nCheckpoint = pindex->nAccumulatorCheckpoint ;
2713+ if (nCheckpoint != pindex->pprev ->nAccumulatorCheckpoint ) {
2714+ if (!CAccumulators::getInstance ().EraseAccumulatorValues (nCheckpoint, pindex->pprev ->nAccumulatorCheckpoint ))
2715+ return error (" DisconnectBlock(): failed to erase checkpoint" );
2716+ }
27132717 }
27142718
27152719 if (pfClean) {
@@ -2946,7 +2950,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
29462950 }
29472951
29482952 // zerocoin accumulator: if a new accumulator checkpoint was generated, check that it is the correct value
2949- if (block.nVersion >= Params ().Zerocoin_HeaderVersion () && pindex->nHeight % 10 == 0 ) {
2953+ if (! fVerifyingBlocks && block.nVersion >= Params ().Zerocoin_HeaderVersion () && pindex->nHeight % 10 == 0 ) {
29502954 uint256 nCheckpointCalculated = 0 ;
29512955 if (!CAccumulators::getInstance ().GetCheckpoint (pindex->nHeight , nCheckpointCalculated))
29522956 return state.DoS (100 , error (" ConnectBlock() : failed to calculate accumulator checkpoint" ));
@@ -2955,7 +2959,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
29552959 LogPrintf (" %s: block=%d calculated: %s\n block: %s\n " , __func__, pindex->nHeight , nCheckpointCalculated.GetHex (), block.nAccumulatorCheckpoint .GetHex ());
29562960 return state.DoS (100 , error (" ConnectBlock() : accumulator does not match calculated value" ));
29572961 }
2958- } else {
2962+ } else if (! fVerifyingBlocks ) {
29592963 if (block.nAccumulatorCheckpoint != pindex->pprev ->nAccumulatorCheckpoint ) {
29602964 return state.DoS (100 , error (" ConnectBlock() : new accumulator checkpoint generated on a block that is not multiple of 10" ));
29612965 }
0 commit comments