Skip to content

Commit fa2c099

Browse files
author
MarcoFalke
committed
wallet: Use steady clock to measure scanning duration
1 parent fa97621 commit fa2c099

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/wallet/rpc/wallet.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ static RPCHelpMan getwalletinfo()
112112
obj.pushKV("avoid_reuse", pwallet->IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE));
113113
if (pwallet->IsScanning()) {
114114
UniValue scanning(UniValue::VOBJ);
115-
scanning.pushKV("duration", pwallet->ScanningDuration() / 1000);
115+
scanning.pushKV("duration", Ticks<std::chrono::seconds>(pwallet->ScanningDuration()));
116116
scanning.pushKV("progress", pwallet->ScanningProgress());
117117
obj.pushKV("scanning", scanning);
118118
} else {

src/wallet/wallet.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
244244
std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
245245
std::atomic<bool> m_attaching_chain{false};
246246
std::atomic<bool> m_scanning_with_passphrase{false};
247-
std::atomic<int64_t> m_scanning_start{0};
247+
std::atomic<SteadyClock::time_point> m_scanning_start{SteadyClock::time_point{}};
248248
std::atomic<double> m_scanning_progress{0};
249249
friend class WalletRescanReserver;
250250

@@ -465,7 +465,7 @@ class CWallet final : public WalletStorage, public interfaces::Chain::Notificati
465465
bool IsAbortingRescan() const { return fAbortRescan; }
466466
bool IsScanning() const { return fScanningWallet; }
467467
bool IsScanningWithPassphrase() const { return m_scanning_with_passphrase; }
468-
int64_t ScanningDuration() const { return fScanningWallet ? GetTimeMillis() - m_scanning_start : 0; }
468+
SteadyClock::duration ScanningDuration() const { return fScanningWallet ? SteadyClock::now() - m_scanning_start.load() : SteadyClock::duration{}; }
469469
double ScanningProgress() const { return fScanningWallet ? (double) m_scanning_progress : 0; }
470470

471471
//! Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo
@@ -971,7 +971,7 @@ class WalletRescanReserver
971971
return false;
972972
}
973973
m_wallet.m_scanning_with_passphrase.exchange(with_passphrase);
974-
m_wallet.m_scanning_start = GetTimeMillis();
974+
m_wallet.m_scanning_start = SteadyClock::now();
975975
m_wallet.m_scanning_progress = 0;
976976
m_could_reserve = true;
977977
return true;

0 commit comments

Comments
 (0)