From 4de630354fc6808b9b13b9e82da1a82f2f50f26a Mon Sep 17 00:00:00 2001 From: Amiti Uttarwar Date: Tue, 5 Nov 2019 11:06:53 +0100 Subject: [tools] add PoissonNextSend method that returns mockable time --- src/net.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/net.h') 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 -- cgit v1.2.3 From 1a8f0d5a74d5cc0000456932babf35301f5c1686 Mon Sep 17 00:00:00 2001 From: Amiti Uttarwar Date: Wed, 30 Oct 2019 15:37:35 -0700 Subject: [tools] update nNextInvSend to use mockable time --- src/net.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/net.h') diff --git a/src/net.h b/src/net.h index ab69e8b82b..c5e7f6c2b1 100644 --- a/src/net.h +++ b/src/net.h @@ -762,7 +762,7 @@ public: bool fSendMempool GUARDED_BY(cs_tx_inventory){false}; // Last time a "MEMPOOL" request was serviced. std::atomic m_last_mempool_req{std::chrono::seconds{0}}; - int64_t nNextInvSend{0}; + std::chrono::microseconds nNextInvSend{0}; CCriticalSection cs_feeFilter; // Minimum fee rate with which to filter inv's to this node -- cgit v1.2.3