aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet.h
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-05-06 11:49:34 +0100
committerfanquake <fanquake@gmail.com>2023-05-06 12:03:50 +0100
commite460c0a24aaa65628f69c475d754cbbbd0eb10ac (patch)
tree09c0bd09a14e3fe7f385cc6d92140301b9d5f8b5 /src/wallet/wallet.h
parent4a72af9ca4c1b3041c8e1f0afa19c49eb8d3006c (diff)
parentfa83fb31619c19a1a30b4181486601a944941b16 (diff)
downloadbitcoin-e460c0a24aaa65628f69c475d754cbbbd0eb10ac.tar.xz
Merge bitcoin/bitcoin#27405: util: Use steady clock instead of system clock to measure durations
fa83fb31619c19a1a30b4181486601a944941b16 wallet: Use steady clock to calculate number of derive iterations (MarcoFalke) fa2c099cec1780a498e198750be0cf5bf0ca315a wallet: Use steady clock to measure scanning duration (MarcoFalke) fa976218044f3ff244abbd797b183a1408375c74 qt: Use steady clock to throttle GUI notifications (MarcoFalke) fa1d8044abc2cd0f149a2d526b3b03441443cdb0 test: Use steady clock in index tests (MarcoFalke) fa454dcb20b9e7943cc25e6eeea72912b5f1c7b5 net: Use steady clock in InterruptibleRecv (MarcoFalke) Pull request description: `GetTimeMillis` has multiple issues: * It doesn't denote the underlying clock type * It isn't type-safe * It is used incorrectly in places that should use a steady clock Fix all issues here. ACKs for top commit: willcl-ark: ACK fa83fb3161 martinus: Code review ACK https://github.com/bitcoin/bitcoin/commit/fa83fb31619c19a1a30b4181486601a944941b16, also ran all tests. All usages of the steady_clock are just for duration measurements, so the change to a different epoch is ok. Tree-SHA512: 5ec4fede8c7f97e2e08863c011856e8304f16ba30a68fdeb42f96a50a04961092cbe46ccf9ea6ac99ff5203c09f9e0924eb483eb38d7df0759addc85116c8a9f
Diffstat (limited to 'src/wallet/wallet.h')
-rw-r--r--src/wallet/wallet.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h
index 5252b46cdc..79f4c43456 100644
--- a/src/wallet/wallet.h
+++ b/src/wallet/wallet.h
@@ -284,7 +284,7 @@ private:
std::atomic<bool> fScanningWallet{false}; // controlled by WalletRescanReserver
std::atomic<bool> m_attaching_chain{false};
std::atomic<bool> m_scanning_with_passphrase{false};
- std::atomic<int64_t> m_scanning_start{0};
+ std::atomic<SteadyClock::time_point> m_scanning_start{SteadyClock::time_point{}};
std::atomic<double> m_scanning_progress{0};
friend class WalletRescanReserver;
@@ -505,7 +505,7 @@ public:
bool IsAbortingRescan() const { return fAbortRescan; }
bool IsScanning() const { return fScanningWallet; }
bool IsScanningWithPassphrase() const { return m_scanning_with_passphrase; }
- int64_t ScanningDuration() const { return fScanningWallet ? GetTimeMillis() - m_scanning_start : 0; }
+ SteadyClock::duration ScanningDuration() const { return fScanningWallet ? SteadyClock::now() - m_scanning_start.load() : SteadyClock::duration{}; }
double ScanningProgress() const { return fScanningWallet ? (double) m_scanning_progress : 0; }
//! Upgrade stored CKeyMetadata objects to store key origin info as KeyOriginInfo
@@ -1014,7 +1014,7 @@ public:
return false;
}
m_wallet.m_scanning_with_passphrase.exchange(with_passphrase);
- m_wallet.m_scanning_start = GetTimeMillis();
+ m_wallet.m_scanning_start = SteadyClock::now();
m_wallet.m_scanning_progress = 0;
m_could_reserve = true;
return true;