mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-12-23 10:28:52 +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
@ -1243,8 +1243,8 @@ namespace nodetool
|
|||||||
if(!max_index)
|
if(!max_index)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
size_t x = crypto::rand<size_t>()%(max_index+1);
|
size_t x = crypto::rand<size_t>()%(16*max_index+1);
|
||||||
size_t res = (x*x*x)/(max_index*max_index); //parabola \/
|
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 << ")");
|
MDEBUG("Random connection index=" << res << "(x="<< x << ", max_index=" << max_index << ")");
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user