aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Schnelli <dev@jonasschnelli.ch>2017-06-23 09:35:24 +0200
committerJonas Schnelli <dev@jonasschnelli.ch>2017-06-29 17:48:12 +0200
commit316fcb5106b90f3dd7a2dced2063e237539e75b4 (patch)
tree14ebde89fd3142ecb820a51857836839b3fe9ab6
parentae09d4583b26251e67fa48216ebafb6bcdf2472b (diff)
downloadbitcoin-316fcb5106b90f3dd7a2dced2063e237539e75b4.tar.xz
Allow to cancel the txdb upgrade via splashscreen callback
-rw-r--r--src/txdb.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/txdb.cpp b/src/txdb.cpp
index 3e05683d1e..6f1d482478 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,9 +368,11 @@ bool CCoinsViewDB::Upgrade() {
return true;
}
+ int64_t count = 0;
LogPrintf("Upgrading database...\n");
size_t batch_size = 1 << 24;
CDBBatch batch(db);
+ uiInterface.SetProgressBreakAction(StartShutdown);
while (pcursor->Valid()) {
boost::this_thread::interruption_point();
if (ShutdownRequested()) {
@@ -376,6 +380,10 @@ bool CCoinsViewDB::Upgrade() {
}
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);
+ uiInterface.ShowProgress(_("Upgrading UTXO database") + "\n"+ _("(press q to shutdown and continue later)") + "\n", (int)(high * 100.0 / 65536.0 + 0.5));
+ }
CCoins old_coins;
if (!pcursor->GetValue(old_coins)) {
return error("%s: cannot parse CCoins record", __func__);
@@ -400,5 +408,6 @@ bool CCoinsViewDB::Upgrade() {
}
}
db.WriteBatch(batch);
+ uiInterface.SetProgressBreakAction(std::function<void(void)>());
return true;
}