aboutsummaryrefslogtreecommitdiff
path: root/src/txdb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/txdb.cpp')
-rw-r--r--src/txdb.cpp23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp
index d24162ba2d..002f6550bc 100644
--- a/src/txdb.cpp
+++ b/src/txdb.cpp
@@ -11,6 +11,8 @@
#include "pow.h"
#include "uint256.h"
#include "util.h"
+#include "ui_interface.h"
+#include "init.h"
#include <stdint.h>
@@ -366,13 +368,30 @@ bool CCoinsViewDB::Upgrade() {
return true;
}
- LogPrintf("Upgrading database...\n");
+ int64_t count = 0;
+ LogPrintf("Upgrading utxo-set database...\n");
+ LogPrintf("[0%%]...");
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()) {
+ break;
+ }
std::pair<unsigned char, uint256> key;
if (pcursor->GetKey(key) && key.first == DB_COINS) {
+ if (count++ % 256 == 0) {
+ uint32_t high = 0x100 * *key.second.begin() + *(key.second.begin() + 1);
+ 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)) {
return error("%s: cannot parse CCoins record", __func__);
@@ -397,5 +416,7 @@ bool CCoinsViewDB::Upgrade() {
}
}
db.WriteBatch(batch);
+ uiInterface.SetProgressBreakAction(std::function<void(void)>());
+ LogPrintf("[%s].\n", ShutdownRequested() ? "CANCELLED" : "DONE");
return true;
}