Skip to content

Commit 83fbea3

Browse files
committed
Report txdb upgrade not more often then every 10%
1 parent 06c5b6e commit 83fbea3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/txdb.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,7 @@ bool CCoinsViewDB::Upgrade() {
374374
size_t batch_size = 1 << 24;
375375
CDBBatch batch(db);
376376
uiInterface.SetProgressBreakAction(StartShutdown);
377+
int reportDone = 0;
377378
while (pcursor->Valid()) {
378379
boost::this_thread::interruption_point();
379380
if (ShutdownRequested()) {
@@ -383,8 +384,13 @@ bool CCoinsViewDB::Upgrade() {
383384
if (pcursor->GetKey(key) && key.first == DB_COINS) {
384385
if (count++ % 256 == 0) {
385386
uint32_t high = 0x100 * *key.second.begin() + *(key.second.begin() + 1);
386-
uiInterface.ShowProgress(_("Upgrading UTXO database") + "\n"+ _("(press q to shutdown and continue later)") + "\n", (int)(high * 100.0 / 65536.0 + 0.5));
387-
LogPrintf("[%d%%]...", (int)(high * 100.0 / 65536.0 + 0.5));
387+
int percentageDone = (int)(high * 100.0 / 65536.0 + 0.5);
388+
uiInterface.ShowProgress(_("Upgrading UTXO database") + "\n"+ _("(press q to shutdown and continue later)") + "\n", percentageDone);
389+
if (reportDone < percentageDone/10) {
390+
// report max. every 10% step
391+
LogPrintf("[%d%%]...", percentageDone);
392+
reportDone = percentageDone/10;
393+
}
388394
}
389395
CCoins old_coins;
390396
if (!pcursor->GetValue(old_coins)) {

0 commit comments

Comments
 (0)