mirror of
https://github.com/monero-project/monero.git
synced 2024-12-28 17:09:41 -05: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
@ -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 New Issue
Block a user