aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorMacroFake <falke.marco@gmail.com>2022-06-23 15:51:16 +0200
committerMacroFake <falke.marco@gmail.com>2022-06-23 15:32:17 +0200
commitfabae3541ac574a1101be8dc54f1499dbbf2f231 (patch)
tree32db283c6c576036e88c84d1c4f5f1f039bc7ae9 /src/util
parent01e9e2d1ca7fc08d65663b398c71ecec6a01f686 (diff)
downloadbitcoin-fabae3541ac574a1101be8dc54f1499dbbf2f231.tar.xz
rpc: Use steady_clock for getrpcinfo durations
Diffstat (limited to 'src/util')
-rw-r--r--src/util/time.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/util/time.h b/src/util/time.h
index ad91a72860..1a381aab9d 100644
--- a/src/util/time.h
+++ b/src/util/time.h
@@ -40,10 +40,15 @@ void UninterruptibleSleep(const std::chrono::microseconds& n);
* This helper is used to convert durations/time_points before passing them over an
* interface that doesn't support std::chrono (e.g. RPC, debug log, or the GUI)
*/
+template <typename Dur1, typename Dur2>
+constexpr auto Ticks(Dur2 d)
+{
+ return std::chrono::duration_cast<Dur1>(d).count();
+}
template <typename Duration, typename Timepoint>
constexpr auto TicksSinceEpoch(Timepoint t)
{
- return std::chrono::time_point_cast<Duration>(t).time_since_epoch().count();
+ return Ticks<Duration>(t.time_since_epoch());
}
constexpr int64_t count_seconds(std::chrono::seconds t) { return t.count(); }
constexpr int64_t count_milliseconds(std::chrono::milliseconds t) { return t.count(); }