aboutsummaryrefslogtreecommitdiff
path: root/src/net.h
diff options
context:
space:
mode:
authorAmiti Uttarwar <amiti@uttarwar.org>2019-11-05 11:06:53 +0100
committerAmiti Uttarwar <amiti@uttarwar.org>2019-11-05 11:06:53 +0100
commit4de630354fc6808b9b13b9e82da1a82f2f50f26a (patch)
tree4fc0563ddd0a33a0859ca71c8527ca1ba6a7c399 /src/net.h
parentdeb2327b435925c6a39ca654a79283b8eb6aeb86 (diff)
[tools] add PoissonNextSend method that returns mockable time
Diffstat (limited to 'src/net.h')
-rw-r--r--src/net.h10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/net.h b/src/net.h
index 44655abf80..ab69e8b82b 100644
--- a/src/net.h
+++ b/src/net.h
@@ -943,11 +943,13 @@ public:
void MaybeSetAddrName(const std::string& addrNameIn);
};
-
-
-
-
/** Return a timestamp in the future (in microseconds) for exponentially distributed events. */
int64_t PoissonNextSend(int64_t now, int average_interval_seconds);
+/** Wrapper to return mockable type */
+inline std::chrono::microseconds PoissonNextSend(std::chrono::microseconds now, std::chrono::seconds average_interval)
+{
+ return std::chrono::microseconds{PoissonNextSend(now.count(), average_interval.count())};
+}
+
#endif // BITCOIN_NET_H