mirror of
https://codeberg.org/anoncontributorxmr/monero.git
synced 2024-12-23 21:57:46 +00:00
p2p: fix cubic selection in filtered peer list
Integer quantization biased the picks a lot (leading some indices to never be selected)
This commit is contained in:
parent
a1eca8ca7e
commit
1d1c430b1f
1 changed files with 2 additions and 2 deletions
|
@ -1243,8 +1243,8 @@ namespace nodetool
|
|||
if(!max_index)
|
||||
return 0;
|
||||
|
||||
size_t x = crypto::rand<size_t>()%(max_index+1);
|
||||
size_t res = (x*x*x)/(max_index*max_index); //parabola \/
|
||||
size_t x = crypto::rand<size_t>()%(16*max_index+1);
|
||||
size_t res = (x*x*x)/(max_index*max_index*16*16*16); //parabola \/
|
||||
MDEBUG("Random connection index=" << res << "(x="<< x << ", max_index=" << max_index << ")");
|
||||
return res;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue