mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
wallet: Use steady clock to measure scanning duration
This commit is contained in:
parent
fa97621804
commit
fa2c099cec
2 changed files with 4 additions and 4 deletions
|
@ -112,7 +112,7 @@ static RPCHelpMan getwalletinfo()
|
|||
obj.pushKV("avoid_reuse", pwallet->IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE));
|
||||
if (pwallet->IsScanning()) {
|
||||
UniValue scanning(UniValue::VOBJ);
|
||||
scanning.pushKV("duration", pwallet->ScanningDuration() / 1000);
|
||||
scanning.pushKV("duration", Ticks<std::chrono::seconds>(pwallet->ScanningDuration()));
|
||||
scanning.pushKV("progress", pwallet->ScanningProgress());
|
||||
obj.pushKV("scanning", scanning);
|
||||
} else {
|
||||
|
|
|
@ -244,7 +244,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;
|
||||
|
||||
|
@ -465,7 +465,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
|
||||
|
@ -971,7 +971,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;
|
||||
|
|
Loading…
Add table
Reference in a new issue