aboutsummaryrefslogtreecommitdiff
path: root/src/random.cpp
diff options
context:
space:
mode:
authorJohn Newbery <john@johnnewbery.com>2020-04-15 19:06:59 -0400
committerMartin Zumsande <mzumsande@gmail.com>2022-01-13 15:55:01 +0100
commitbb060746df22c956b8f44e5b8cd1ae4ed73faddc (patch)
tree66201fcfa055bb7cc9de4dc691ff163fa79eb0d6 /src/random.cpp
parent03cfa1b6035dbcf6a414f9bc432bd9e612801ebb (diff)
scripted-diff: replace PoissonNextSend with GetExponentialRand
This distribution is used for more than just the next inv send, so make the name more generic. Also rename to "exponential" to avoid the confusion that this is a poisson distribution. -BEGIN VERIFY SCRIPT- ren() { sed -i "s/\<$1\>/$2/g" $(git grep -l "$1" ./src) ; } ren PoissonNextSend GetExponentialRand ren "a poisson timer" "an exponential timer" -END VERIFY SCRIPT-
Diffstat (limited to 'src/random.cpp')
-rw-r--r--src/random.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/random.cpp b/src/random.cpp
index 03b8d7530d..5dae80fe31 100644
--- a/src/random.cpp
+++ b/src/random.cpp
@@ -716,7 +716,7 @@ void RandomInit()
ReportHardwareRand();
}
-std::chrono::microseconds PoissonNextSend(std::chrono::microseconds now, std::chrono::seconds average_interval)
+std::chrono::microseconds GetExponentialRand(std::chrono::microseconds now, std::chrono::seconds average_interval)
{
double unscaled = -std::log1p(GetRand(uint64_t{1} << 48) * -0.0000000000000035527136788 /* -1/2^48 */);
return now + std::chrono::duration_cast<std::chrono::microseconds>(unscaled * average_interval + 0.5us);