Skip to content

Commit

Permalink
Report txdb upgrade not more often then every 10%
Browse files Browse the repository at this point in the history
Cherry-picked from: 83fbea3
  • Loading branch information
jonasschnelli authored and xanimo committed Dec 19, 2024
1 parent deb2a9f commit ad18c04
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/txdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ bool CCoinsViewDB::Upgrade() {
size_t batch_size = 1 << 24;
CDBBatch batch(db);
uiInterface.SetProgressBreakAction(StartShutdown);
int reportDone = 0;
while (pcursor->Valid()) {
boost::this_thread::interruption_point();
if (ShutdownRequested()) {
Expand All @@ -391,8 +392,13 @@ bool CCoinsViewDB::Upgrade() {
if (pcursor->GetKey(key) && key.first == DB_COINS) {
if (count++ % 256 == 0) {
uint32_t high = 0x100 * *key.second.begin() + *(key.second.begin() + 1);
uiInterface.ShowProgress(_("Upgrading UTXO database") + "\n"+ _("(press q to shutdown and continue later)") + "\n", (int)(high * 100.0 / 65536.0 + 0.5));
LogPrintf("[%d%%]...", (int)(high * 100.0 / 65536.0 + 0.5));
int percentageDone = (int)(high * 100.0 / 65536.0 + 0.5);
uiInterface.ShowProgress(_("Upgrading UTXO database") + "\n"+ _("(press q to shutdown and continue later)") + "\n", percentageDone);
if (reportDone < percentageDone/10) {
// report max. every 10% step
LogPrintf("[%d%%]...", percentageDone);
reportDone = percentageDone/10;
}
}
CCoins old_coins;
if (!pcursor->GetValue(old_coins)) {
Expand Down

0 comments on commit ad18c04

Please sign in to comment.