Skip to content

Commit

Permalink
[Qt] Show progress percent for zpiv reindex operations
Browse files Browse the repository at this point in the history
`-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.
  • Loading branch information
Fuzzbawls committed May 22, 2018
1 parent 6b73598 commit 48e502a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2760,6 +2760,7 @@ bool RecalculatePIVSupply(int nHeightStart)
bool ReindexAccumulators(list<uint256>& listMissingCheckpoints, string& strError)
{
// PIVX: recalculate Accumulator Checkpoints that failed to database properly
uiInterface.ShowProgress(_("Calculating missing accumulators..."), 0);
if (!listMissingCheckpoints.empty() && chainActive.Height() >= Params().Zerocoin_StartHeight()) {
LogPrintf("%s : finding missing checkpoints\n", __func__);

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

if (ShutdownRequested())
return false;

Expand Down Expand Up @@ -2799,6 +2802,7 @@ bool ReindexAccumulators(list<uint256>& listMissingCheckpoints, string& strError
}
pindex = chainActive.Next(pindex);
}
uiInterface.ShowProgress("", 100);
}
return true;
}
Expand Down
5 changes: 5 additions & 0 deletions src/zpivchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,12 @@ std::string ReindexZerocoinDB()
return _("Failed to wipe zerocoinDB");
}

uiInterface.ShowProgress(_("Reindexing zerocoin database..."), 0);

CBlockIndex* pindex = chainActive[Params().Zerocoin_StartHeight()];
while (pindex) {
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))));

if (pindex->nHeight % 1000 == 0)
LogPrintf("Reindexing zerocoin : block %d...\n", pindex->nHeight);

Expand Down Expand Up @@ -304,6 +308,7 @@ std::string ReindexZerocoinDB()
}
pindex = chainActive.Next(pindex);
}
uiInterface.ShowProgress("", 100);

return "";
}
Expand Down

0 comments on commit 48e502a

Please sign in to comment.