Skip to content

Commit 90e27ab

Browse files
committed
wallet: Track current scanning progress
1 parent 2ee811e commit 90e27ab

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/wallet/wallet.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1798,8 +1798,9 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
17981798
}
17991799
double progress_current = progress_begin;
18001800
while (block_height && !fAbortRescan && !chain().shutdownRequested()) {
1801+
m_scanning_progress = (progress_current - progress_begin) / (progress_end - progress_begin);
18011802
if (*block_height % 100 == 0 && progress_end - progress_begin > 0.0) {
1802-
ShowProgress(strprintf("%s " + _("Rescanning..."), GetDisplayName()), std::max(1, std::min(99, (int)((progress_current - progress_begin) / (progress_end - progress_begin) * 100))));
1803+
ShowProgress(strprintf("%s " + _("Rescanning..."), GetDisplayName()), std::max(1, std::min(99, (int)(m_scanning_progress * 100))));
18031804
}
18041805
if (GetTime() >= nNow + 60) {
18051806
nNow = GetTime();

src/wallet/wallet.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ class CWallet final : public CCryptoKeyStore, private interfaces::Chain::Notific
597597
std::atomic<bool> fAbortRescan{false};
598598
std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
599599
std::atomic<int64_t> m_scanning_start{0};
600+
std::atomic<double> m_scanning_progress{0};
600601
std::mutex mutexScanning;
601602
friend class WalletRescanReserver;
602603

@@ -822,6 +823,7 @@ class CWallet final : public CCryptoKeyStore, private interfaces::Chain::Notific
822823
bool IsAbortingRescan() { return fAbortRescan; }
823824
bool IsScanning() { return fScanningWallet; }
824825
int64_t ScanningDuration() const { return fScanningWallet ? GetTimeMillis() - m_scanning_start : 0; }
826+
double ScanningProgress() const { return fScanningWallet ? (double) m_scanning_progress : 0; }
825827

826828
/**
827829
* keystore implementation
@@ -1244,6 +1246,7 @@ class WalletRescanReserver
12441246
return false;
12451247
}
12461248
m_wallet->m_scanning_start = GetTimeMillis();
1249+
m_wallet->m_scanning_progress = 0;
12471250
m_wallet->fScanningWallet = true;
12481251
m_could_reserve = true;
12491252
return true;

0 commit comments

Comments
 (0)