mirror of
https://github.com/monero-project/monero.git
synced 2024-10-01 11:49:47 -04:00
Merge pull request #5317
1730a44f
core: improve block rate monitor trigger probabilities (moneromooo-monero)
This commit is contained in:
commit
55d7eb06a8
@ -1784,12 +1784,28 @@ namespace cryptonote
|
||||
return f;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
static double probability(unsigned int blocks, unsigned int expected)
|
||||
static double probability1(unsigned int blocks, unsigned int expected)
|
||||
{
|
||||
// https://www.umass.edu/wsp/resources/poisson/#computing
|
||||
return pow(expected, blocks) / (factorial(blocks) * exp(expected));
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
static double probability(unsigned int blocks, unsigned int expected)
|
||||
{
|
||||
double p = 0.0;
|
||||
if (blocks <= expected)
|
||||
{
|
||||
for (unsigned int b = 0; b <= blocks; ++b)
|
||||
p += probability1(b, expected);
|
||||
}
|
||||
else if (blocks > expected)
|
||||
{
|
||||
for (unsigned int b = blocks; b <= expected * 3 /* close enough */; ++b)
|
||||
p += probability1(b, expected);
|
||||
}
|
||||
return p;
|
||||
}
|
||||
//-----------------------------------------------------------------------------------------------
|
||||
bool core::check_block_rate()
|
||||
{
|
||||
if (m_offline || m_target_blockchain_height > get_current_blockchain_height())
|
||||
|
Loading…
Reference in New Issue
Block a user