@@ -1707,8 +1707,10 @@ int64_t CWallet::RescanFromTime(int64_t startTime, const WalletRescanReserver& r
1707
1707
*/
1708
1708
CWallet::ScanResult CWallet::ScanForWalletTransactions (const uint256& start_block, int start_height, std::optional<int > max_height, const WalletRescanReserver& reserver, bool fUpdate )
1709
1709
{
1710
- int64_t nNow = GetTime ();
1711
- int64_t start_time = GetTimeMillis ();
1710
+ using Clock = std::chrono::steady_clock;
1711
+ constexpr auto LOG_INTERVAL{60s};
1712
+ auto current_time{Clock::now ()};
1713
+ auto start_time{Clock::now ()};
1712
1714
1713
1715
assert (reserver.isReserved ());
1714
1716
@@ -1735,8 +1737,8 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
1735
1737
if (block_height % 100 == 0 && progress_end - progress_begin > 0.0 ) {
1736
1738
ShowProgress (strprintf (" %s " + _ (" Rescanning…" ).translated , GetDisplayName ()), std::max (1 , std::min (99 , (int )(m_scanning_progress * 100 ))));
1737
1739
}
1738
- if (GetTime () >= nNow + 60 ) {
1739
- nNow = GetTime ();
1740
+ if (Clock::now () >= current_time + LOG_INTERVAL ) {
1741
+ current_time = Clock::now ();
1740
1742
WalletLogPrintf (" Still rescanning. At block %d. Progress=%f\n " , block_height, progress_current);
1741
1743
}
1742
1744
@@ -1803,7 +1805,8 @@ CWallet::ScanResult CWallet::ScanForWalletTransactions(const uint256& start_bloc
1803
1805
WalletLogPrintf (" Rescan interrupted by shutdown request at block %d. Progress=%f\n " , block_height, progress_current);
1804
1806
result.status = ScanResult::USER_ABORT;
1805
1807
} else {
1806
- WalletLogPrintf (" Rescan completed in %15dms\n " , GetTimeMillis () - start_time);
1808
+ auto duration_milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(Clock::now () - start_time);
1809
+ WalletLogPrintf (" Rescan completed in %15dms\n " , duration_milliseconds.count ());
1807
1810
}
1808
1811
return result;
1809
1812
}
0 commit comments