aboutsummaryrefslogtreecommitdiff
path: root/src/p2p/net_node.inl
diff options
context:
space:
mode:
authormoneromooo <moneromoo@nowhere.nowhere.nowhere>2021-01-01 15:27:15 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2021-01-01 15:44:36 +0000
commit1d1c430b1f071f43549e30d4f11bc1d56f071c03 (patch)
tree3c2819034e249d1d5ee03b3086543862094eecd4 /src/p2p/net_node.inl
parentMerge pull request #7221 (diff)
downloadmonero-1d1c430b1f071f43549e30d4f11bc1d56f071c03.tar.xz
p2p: fix cubic selection in filtered peer list
Integer quantization biased the picks a lot (leading some indices to never be selected)
Diffstat (limited to 'src/p2p/net_node.inl')
-rw-r--r--src/p2p/net_node.inl4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index bf053f0f2..315ebfdde 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -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;
}