From 48e502aa2e9a22911f92eb0e5ea9422c6facf4c4 Mon Sep 17 00:00:00 2001 From: Fuzzbawls Date: Fri, 11 May 2018 22:19:32 -0700 Subject: [PATCH] [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. --- src/main.cpp | 4 ++++ src/zpivchain.cpp | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index b01e771173f0b..a487593662b99 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2760,6 +2760,7 @@ bool RecalculatePIVSupply(int nHeightStart) bool ReindexAccumulators(list& 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__); @@ -2769,6 +2770,8 @@ bool ReindexAccumulators(list& 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; @@ -2799,6 +2802,7 @@ bool ReindexAccumulators(list& listMissingCheckpoints, string& strError } pindex = chainActive.Next(pindex); } + uiInterface.ShowProgress("", 100); } return true; } diff --git a/src/zpivchain.cpp b/src/zpivchain.cpp index 985e33927ca9c..480d96ce4d83e 100644 --- a/src/zpivchain.cpp +++ b/src/zpivchain.cpp @@ -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); @@ -304,6 +308,7 @@ std::string ReindexZerocoinDB() } pindex = chainActive.Next(pindex); } + uiInterface.ShowProgress("", 100); return ""; }