mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
[tools] add PoissonNextSend method that returns mockable time
This commit is contained in:
10
src/net.h
10
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
|
||||
|
||||
Reference in New Issue
Block a user