diff options
author | João Barbosa <joao.paulo.barbosa@gmail.com> | 2019-04-03 17:05:52 +0100 |
---|---|---|
committer | João Barbosa <joao.paulo.barbosa@gmail.com> | 2019-05-02 11:39:05 +0100 |
commit | 90e27abe37cc84c7b206f20d28aafe32e71e7209 (patch) | |
tree | 63c0b37628faf68eeb94d7dadf0e3d0c2979e211 /src | |
parent | 2ee811e6930cf76ea51e6826fe437ed888688adc (diff) |
wallet: Track current scanning progress
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/wallet.cpp | 3 | ||||
-rw-r--r-- | src/wallet/wallet.h | 3 |
2 files changed, 5 insertions, 1 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 4ab94f0c2c..1a34706133 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1798,8 +1798,9 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc } double progress_current = progress_begin; while (block_height && !fAbortRescan && !chain().shutdownRequested()) { + m_scanning_progress = (progress_current - progress_begin) / (progress_end - progress_begin); if (*block_height % 100 == 0 && progress_end - progress_begin > 0.0) { - ShowProgress(strprintf("%s " + _("Rescanning..."), GetDisplayName()), std::max(1, std::min(99, (int)((progress_current - progress_begin) / (progress_end - progress_begin) * 100)))); + ShowProgress(strprintf("%s " + _("Rescanning..."), GetDisplayName()), std::max(1, std::min(99, (int)(m_scanning_progress * 100)))); } if (GetTime() >= nNow + 60) { nNow = GetTime(); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index fa9a13bebb..aa6ce058e6 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -597,6 +597,7 @@ private: std::atomic<bool> fAbortRescan{false}; std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver std::atomic<int64_t> m_scanning_start{0}; + std::atomic<double> m_scanning_progress{0}; std::mutex mutexScanning; friend class WalletRescanReserver; @@ -822,6 +823,7 @@ public: bool IsAbortingRescan() { return fAbortRescan; } bool IsScanning() { return fScanningWallet; } int64_t ScanningDuration() const { return fScanningWallet ? GetTimeMillis() - m_scanning_start : 0; } + double ScanningProgress() const { return fScanningWallet ? (double) m_scanning_progress : 0; } /** * keystore implementation @@ -1244,6 +1246,7 @@ public: return false; } m_wallet->m_scanning_start = GetTimeMillis(); + m_wallet->m_scanning_progress = 0; m_wallet->fScanningWallet = true; m_could_reserve = true; return true; |