|
11 | 11 |
|
12 | 12 | #include "init.h" |
13 | 13 |
|
| 14 | +#include "accumulatorcheckpoints.h" |
14 | 15 | #include "accumulators.h" |
15 | 16 | #include "activemasternode.h" |
16 | 17 | #include "addrman.h" |
|
39 | 40 | #include "util.h" |
40 | 41 | #include "utilmoneystr.h" |
41 | 42 | #include "validationinterface.h" |
42 | | -#include "accumulatorcheckpoints.h" |
| 43 | +#include "zpivchain.h" |
43 | 44 |
|
44 | 45 | #ifdef ENABLE_WALLET |
45 | 46 | #include "db.h" |
@@ -1437,57 +1438,11 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) |
1437 | 1438 | // Drop all information from the zerocoinDB and repopulate |
1438 | 1439 | if (GetBoolArg("-reindexzerocoin", false)) { |
1439 | 1440 | uiInterface.InitMessage(_("Reindexing zerocoin database...")); |
1440 | | - if (!zerocoinDB->WipeCoins("spends") || !zerocoinDB->WipeCoins("mints")) { |
1441 | | - strLoadError = _("Failed to wipe zerocoinDB"); |
| 1441 | + std::string strError = ReindexZerocoinDB(); |
| 1442 | + if (strError != "") { |
| 1443 | + strLoadError = strError; |
1442 | 1444 | break; |
1443 | 1445 | } |
1444 | | - |
1445 | | - CBlockIndex* pindex = chainActive[Params().Zerocoin_StartHeight()]; |
1446 | | - while (pindex) { |
1447 | | - if (pindex->nHeight % 1000 == 0) |
1448 | | - LogPrintf("Reindexing zerocoin : block %d...\n", pindex->nHeight); |
1449 | | - |
1450 | | - CBlock block; |
1451 | | - if (!ReadBlockFromDisk(block, pindex)) { |
1452 | | - strLoadError = _("Reindexing zerocoin failed"); |
1453 | | - break; |
1454 | | - } |
1455 | | - |
1456 | | - for (const CTransaction& tx : block.vtx) { |
1457 | | - for (unsigned int i = 0; i < tx.vin.size(); i++) { |
1458 | | - if (tx.IsCoinBase()) |
1459 | | - break; |
1460 | | - |
1461 | | - if (tx.ContainsZerocoins()) { |
1462 | | - uint256 txid = tx.GetHash(); |
1463 | | - //Record Serials |
1464 | | - if (tx.IsZerocoinSpend()) { |
1465 | | - for (auto& in : tx.vin) { |
1466 | | - if (!in.scriptSig.IsZerocoinSpend()) |
1467 | | - continue; |
1468 | | - |
1469 | | - libzerocoin::CoinSpend spend = TxInToZerocoinSpend(in); |
1470 | | - zerocoinDB->WriteCoinSpend(spend.getCoinSerialNumber(), txid); |
1471 | | - } |
1472 | | - } |
1473 | | - |
1474 | | - //Record mints |
1475 | | - if (tx.IsZerocoinMint()) { |
1476 | | - for (auto& out : tx.vout) { |
1477 | | - if (!out.IsZerocoinMint()) |
1478 | | - continue; |
1479 | | - |
1480 | | - CValidationState state; |
1481 | | - libzerocoin::PublicCoin coin(Params().Zerocoin_Params(pindex->nHeight < Params().Zerocoin_Block_V2_Start())); |
1482 | | - TxOutToPublicCoin(out, coin, state); |
1483 | | - zerocoinDB->WriteCoinMint(coin, txid); |
1484 | | - } |
1485 | | - } |
1486 | | - } |
1487 | | - } |
1488 | | - } |
1489 | | - pindex = chainActive.Next(pindex); |
1490 | | - } |
1491 | 1446 | } |
1492 | 1447 |
|
1493 | 1448 | // Recalculate money supply for blocks that are impacted by accounting issue after zerocoin activation |
|
0 commit comments