aboutsummaryrefslogtreecommitdiff
path: root/src/rpcdump.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <[email protected]>2014-04-23 17:02:59 +0200
committerWladimir J. van der Laan <[email protected]>2014-04-23 17:05:05 +0200
commit97730c9b7f0f0e6f157f2d90adb38a014e0b93e2 (patch)
treed15dfbbcc39a5d93b78fb825fbec1add59bbdb08 /src/rpcdump.cpp
parentMerge pull request #4042 (diff)
parent[Qt] importwallet progress (diff)
downloaddiscoin-97730c9b7f0f0e6f157f2d90adb38a014e0b93e2.tar.xz
discoin-97730c9b7f0f0e6f157f2d90adb38a014e0b93e2.zip
Merge pull request #4055
bb1f1c9 [Qt] importwallet progress (Cozz Lovan)
Diffstat (limited to 'src/rpcdump.cpp')
-rw-r--r--src/rpcdump.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/rpcdump.cpp b/src/rpcdump.cpp
index 9a24a99c1..593e0d2b6 100644
--- a/src/rpcdump.cpp
+++ b/src/rpcdump.cpp
@@ -153,7 +153,7 @@ Value importwallet(const Array& params, bool fHelp)
EnsureWalletIsUnlocked();
ifstream file;
- file.open(params[0].get_str().c_str());
+ file.open(params[0].get_str().c_str(), std::ios::in | std::ios::ate);
if (!file.is_open())
throw JSONRPCError(RPC_INVALID_PARAMETER, "Cannot open wallet dump file");
@@ -161,7 +161,12 @@ Value importwallet(const Array& params, bool fHelp)
bool fGood = true;
+ int64_t nFilesize = std::max((int64_t)1, (int64_t)file.tellg());
+ file.seekg(0, file.beg);
+
+ pwalletMain->ShowProgress(_("Importing..."), 0); // show progress dialog in GUI
while (file.good()) {
+ pwalletMain->ShowProgress("", std::max(1, std::min(99, (int)(((double)file.tellg() / (double)nFilesize) * 100))));
std::string line;
std::getline(file, line);
if (line.empty() || line[0] == '#')
@@ -207,6 +212,7 @@ Value importwallet(const Array& params, bool fHelp)
nTimeBegin = std::min(nTimeBegin, nTime);
}
file.close();
+ pwalletMain->ShowProgress("", 100); // hide progress dialog in GUI
CBlockIndex *pindex = chainActive.Tip();
while (pindex && pindex->pprev && pindex->nTime > nTimeBegin - 7200)