diff options
author | fanquake <fanquake@gmail.com> | 2023-03-23 10:02:58 +0000 |
---|---|---|
committer | fanquake <fanquake@gmail.com> | 2023-03-23 10:17:23 +0000 |
commit | 2fadb261b6b6b65355e23207d6168d5c6c03b533 (patch) | |
tree | 01259a31c6aeb4de1bcf079d60d469b3419855e5 /src/util | |
parent | 4c6b7d330a4e80460dcce19b1a0a47d77a0b99ea (diff) | |
parent | faf3f12424fa8558e65fa3f1dd3aa1d0eea8604e (diff) |
Merge bitcoin/bitcoin#27233: refactor: Replace GetTimeMicros by SystemClock
faf3f12424fa8558e65fa3f1dd3aa1d0eea8604e refactor: Replace GetTimeMicros by SystemClock (MarcoFalke)
Pull request description:
It is unclear from the name that `GetTimeMicros` returns the system time. Also, it is not using the type-safe `std::chrono` types.
Fix both issues by replacing it with `SystemClock` in the only place it is used.
This refactor should not change behavior.
ACKs for top commit:
willcl-ark:
tACK faf3f1242
john-moffett:
ACK faf3f12424fa8558e65fa3f1dd3aa1d0eea8604e changes, but left a comment for the existing code.
Tree-SHA512: 069e6ef26467a469f128b98a4aeb334f141742befd7880cb3a7d280480e9f0684dc0686fa6a828cdcb3d11943ae5c7f8ad5d9d9dab4c668be85e5d28c78cd489
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/time.cpp | 5 | ||||
-rw-r--r-- | src/util/time.h | 10 |
2 files changed, 5 insertions, 10 deletions
diff --git a/src/util/time.cpp b/src/util/time.cpp index 58200c83fc..fb9bc34931 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -107,11 +107,6 @@ int64_t GetTimeMillis() return int64_t{GetSystemTime<std::chrono::milliseconds>().count()}; } -int64_t GetTimeMicros() -{ - return int64_t{GetSystemTime<std::chrono::microseconds>().count()}; -} - int64_t GetTime() { return GetTime<std::chrono::seconds>().count(); } std::string FormatISO8601DateTime(int64_t nTime) { diff --git a/src/util/time.h b/src/util/time.h index fcf85c1e03..8c6baeb12a 100644 --- a/src/util/time.h +++ b/src/util/time.h @@ -29,6 +29,8 @@ using SteadySeconds = std::chrono::time_point<std::chrono::steady_clock, std::ch using SteadyMilliseconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::milliseconds>; using SteadyMicroseconds = std::chrono::time_point<std::chrono::steady_clock, std::chrono::microseconds>; +using SystemClock = std::chrono::system_clock; + void UninterruptibleSleep(const std::chrono::microseconds& n); /** @@ -63,16 +65,14 @@ using MillisecondsDouble = std::chrono::duration<double, std::chrono::millisecon * DEPRECATED * Use either ClockType::now() or Now<TimePointType>() if a cast is needed. * ClockType is - * - std::chrono::steady_clock for steady time - * - std::chrono::system_clock for system time - * - NodeClock for mockable system time + * - SteadyClock/std::chrono::steady_clock for steady time + * - SystemClock/std::chrono::system_clock for system time + * - NodeClock for mockable system time */ int64_t GetTime(); /** Returns the system time (not mockable) */ int64_t GetTimeMillis(); -/** Returns the system time (not mockable) */ -int64_t GetTimeMicros(); /** * DEPRECATED |