aboutsummaryrefslogtreecommitdiff
path: root/src/util
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@protonmail.com>2019-10-02 16:55:03 +0200
committerWladimir J. van der Laan <laanwj@protonmail.com>2019-10-02 16:55:36 +0200
commitccaef6c28b1997bd40faad2e1c66e22cdda11edc (patch)
treebec38b34fad46cea3a4102299a38ae6032dd7456 /src/util
parent19ba43ae2d00d00fde280b43fba4af98d863f547 (diff)
parentfaec689bed7a5b66e2a7675853d10205b933cec8 (diff)
downloadbitcoin-ccaef6c28b1997bd40faad2e1c66e22cdda11edc.tar.xz
Merge #16908: txmempool: Make entry time type-safe (std::chrono)
faec689bed7a5b66e2a7675853d10205b933cec8 txmempool: Make entry time type-safe (std::chrono) (MarcoFalke) faaa1f01daba94b021ca77515266a16d27f0364e util: Add count_seconds time helper (MarcoFalke) 1111170f2f0141084b5b4ed565b2f07eba48599a test: mempool entry time is persisted (MarcoFalke) Pull request description: This changes the type of the entry time of txs into the mempool from `int64_t` to `std::chrono::seconds`. The benefits: * Documents the type for developers * Type violations result in compile errors * After compilation, the two are equivalent (at no run time cost) ACKs for top commit: ajtowns: utACK faec689bed7a5b66e2a7675853d10205b933cec8 laanwj: ACK faec689bed7a5b66e2a7675853d10205b933cec8 Tree-SHA512: d958e058755d1a1d54cef536a8b30a11cc502b7df0d6ecf84a0ab1d38bc8105a67668a99cd5087a444f6de2421238111c5fca133cdf8e2e2273cb12cb6957845
Diffstat (limited to 'src/util')
-rw-r--r--src/util/time.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/util/time.h b/src/util/time.h
index e4f9996777..c0470a2136 100644
--- a/src/util/time.h
+++ b/src/util/time.h
@@ -11,6 +11,14 @@
#include <chrono>
/**
+ * Helper to count the seconds of a duration.
+ *
+ * All durations should be using std::chrono and calling this should generally be avoided in code. Though, it is still
+ * preferred to an inline t.count() to protect against a reliance on the exact type of t.
+ */
+inline int64_t count_seconds(std::chrono::seconds t) { return t.count(); }
+
+/**
* DEPRECATED
* Use either GetSystemTimeInSeconds (not mockable) or GetTime<T> (mockable)
*/