From 4d98b401fbd821700f7a792b0a4cb52c9b71bc9f Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 29 Sep 2020 19:11:53 -0700 Subject: Change all ping times to std::chrono types --- src/util/time.h | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/util') diff --git a/src/util/time.h b/src/util/time.h index 56131ce0fe..9b418637c3 100644 --- a/src/util/time.h +++ b/src/util/time.h @@ -30,6 +30,13 @@ inline int64_t count_seconds(std::chrono::seconds t) { return t.count(); } inline int64_t count_milliseconds(std::chrono::milliseconds t) { return t.count(); } inline int64_t count_microseconds(std::chrono::microseconds t) { return t.count(); } +using SecondsDouble = std::chrono::duration; + +/** + * Helper to count the seconds in any std::chrono::duration type + */ +inline double CountSecondsDouble(SecondsDouble t) { return t.count(); } + /** * DEPRECATED * Use either GetSystemTimeInSeconds (not mockable) or GetTime (mockable) -- cgit v1.2.3 From 55e82881a1503bff146970856c1474a6ea659c94 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Tue, 29 Sep 2020 20:19:57 -0700 Subject: Make all Poisson delays use std::chrono types --- src/util/time.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src/util') diff --git a/src/util/time.h b/src/util/time.h index 9b418637c3..7ebcaaa339 100644 --- a/src/util/time.h +++ b/src/util/time.h @@ -26,9 +26,9 @@ void UninterruptibleSleep(const std::chrono::microseconds& n); * This helper is used to convert durations before passing them over an * interface that doesn't support std::chrono (e.g. RPC, debug log, or the GUI) */ -inline int64_t count_seconds(std::chrono::seconds t) { return t.count(); } -inline int64_t count_milliseconds(std::chrono::milliseconds t) { return t.count(); } -inline int64_t count_microseconds(std::chrono::microseconds t) { return t.count(); } +constexpr int64_t count_seconds(std::chrono::seconds t) { return t.count(); } +constexpr int64_t count_milliseconds(std::chrono::milliseconds t) { return t.count(); } +constexpr int64_t count_microseconds(std::chrono::microseconds t) { return t.count(); } using SecondsDouble = std::chrono::duration; -- cgit v1.2.3