diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -795,6 +795,7 @@ // controlled by WalletRescanReserver std::atomic fScanningWallet{false}; std::atomic m_scanning_start{0}; + std::atomic m_scanning_progress{0}; std::mutex mutexScanning; friend class WalletRescanReserver; @@ -1124,6 +1125,9 @@ int64_t ScanningDuration() const { return fScanningWallet ? GetTimeMillis() - m_scanning_start : 0; } + double ScanningProgress() const { + return fScanningWallet ? double(m_scanning_progress) : 0; + } /** * keystore implementation @@ -1681,6 +1685,7 @@ return false; } m_wallet->m_scanning_start = GetTimeMillis(); + m_wallet->m_scanning_progress = 0; m_wallet->fScanningWallet = true; m_could_reserve = true; return true; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2203,16 +2203,14 @@ } 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...").translated, GetDisplayName()), - std::max( - 1, - std::min(99, (int)((progress_current - progress_begin) / - (progress_end - progress_begin) * - 100)))); + std::max(1, std::min(99, int(m_scanning_progress * 100)))); } if (GetTime() >= nNow + 60) { nNow = GetTime();