@@ -1939,8 +1939,10 @@ int64_t CWallet::RescanFromTime(int64_t startTime, const WalletRescanReserver& r
1939
1939
*/
1940
1940
CWallet::ScanResult CWallet::ScanForWalletTransactions (const uint256& start_block, int start_height, std::optional<int > max_height, const WalletRescanReserver& reserver, bool fUpdate )
1941
1941
{
1942
- int64_t nNow = GetTime ();
1943
- int64_t start_time = GetTimeMillis ();
1942
+ using Clock = std::chrono::steady_clock;
1943
+ constexpr auto LOG_INTERVAL{60s};
1944
+ auto current_time{Clock::now ()};
1945
+ auto start_time{Clock::now ()};
1944
1946
1945
1947
assert (reserver.isReserved ());
1946
1948
@@ -1967,8 +1969,8 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
1967
1969
if (block_height % 100 == 0 && progress_end - progress_begin > 0.0 ) {
1968
1970
ShowProgress (strprintf (" %s " + _ (" Rescanning..." ).translated , GetDisplayName ()), std::max (1 , std::min (99 , (int )(m_scanning_progress * 100 ))));
1969
1971
}
1970
- if (GetTime () >= nNow + 60 ) {
1971
- nNow = GetTime ();
1972
+ if (Clock::now () >= current_time + LOG_INTERVAL ) {
1973
+ current_time = Clock::now ();
1972
1974
WalletLogPrintf (" Still rescanning. At block %d. Progress=%f\n " , block_height, progress_current);
1973
1975
}
1974
1976
@@ -2035,7 +2037,8 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
2035
2037
WalletLogPrintf (" Rescan interrupted by shutdown request at block %d. Progress=%f\n " , block_height, progress_current);
2036
2038
result.status = ScanResult::USER_ABORT;
2037
2039
} else {
2038
- WalletLogPrintf (" Rescan completed in %15dms\n " , GetTimeMillis () - start_time);
2040
+ auto duration_milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(Clock::now () - start_time);
2041
+ WalletLogPrintf (" Rescan completed in %15dms\n " , duration_milliseconds.count ());
2039
2042
}
2040
2043
return result;
2041
2044
}
0 commit comments