[Qt] importwallet progress

This commit is contained in:
Cozz Lovan 2014-04-14 19:59:22 +02:00 committed by langerhans
parent d8701eb7ad
commit 8a75a1f87f

View file

@ -154,7 +154,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");
@ -162,7 +162,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] == '#')
@ -208,6 +213,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)