Skip to content

Commit 48e502a

Browse files
committed
[Qt] Show progress percent for zpiv reindex operations
`-reindexaccumulators` and `-reindexzerocoin` can take a considerable time to complete depending on system hardware. Lets show a progress percent similar to `VerifyDB()` on the splashscreen.
1 parent 6b73598 commit 48e502a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/main.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2760,6 +2760,7 @@ bool RecalculatePIVSupply(int nHeightStart)
27602760
bool ReindexAccumulators(list<uint256>& listMissingCheckpoints, string& strError)
27612761
{
27622762
// PIVX: recalculate Accumulator Checkpoints that failed to database properly
2763+
uiInterface.ShowProgress(_("Calculating missing accumulators..."), 0);
27632764
if (!listMissingCheckpoints.empty() && chainActive.Height() >= Params().Zerocoin_StartHeight()) {
27642765
LogPrintf("%s : finding missing checkpoints\n", __func__);
27652766

@@ -2769,6 +2770,8 @@ bool ReindexAccumulators(list<uint256>& listMissingCheckpoints, string& strError
27692770
// find each checkpoint that is missing
27702771
CBlockIndex* pindex = chainActive[nZerocoinStart];
27712772
while (pindex) {
2773+
uiInterface.ShowProgress(_("Calculating missing accumulators..."), std::max(1, std::min(99, (int)((double)(pindex->nHeight - nZerocoinStart) / (double)(chainActive.Height() - nZerocoinStart) * 100))));
2774+
27722775
if (ShutdownRequested())
27732776
return false;
27742777

@@ -2799,6 +2802,7 @@ bool ReindexAccumulators(list<uint256>& listMissingCheckpoints, string& strError
27992802
}
28002803
pindex = chainActive.Next(pindex);
28012804
}
2805+
uiInterface.ShowProgress("", 100);
28022806
}
28032807
return true;
28042808
}

src/zpivchain.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,12 @@ std::string ReindexZerocoinDB()
259259
return _("Failed to wipe zerocoinDB");
260260
}
261261

262+
uiInterface.ShowProgress(_("Reindexing zerocoin database..."), 0);
263+
262264
CBlockIndex* pindex = chainActive[Params().Zerocoin_StartHeight()];
263265
while (pindex) {
266+
uiInterface.ShowProgress(_("Reindexing zerocoin database..."), std::max(1, std::min(99, (int)((double)(pindex->nHeight - Params().Zerocoin_StartHeight()) / (double)(chainActive.Height() - Params().Zerocoin_StartHeight()) * 100))));
267+
264268
if (pindex->nHeight % 1000 == 0)
265269
LogPrintf("Reindexing zerocoin : block %d...\n", pindex->nHeight);
266270

@@ -304,6 +308,7 @@ std::string ReindexZerocoinDB()
304308
}
305309
pindex = chainActive.Next(pindex);
306310
}
311+
uiInterface.ShowProgress("", 100);
307312

308313
return "";
309314
}

0 commit comments

Comments
 (0)