aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMiguel Herranz <miguel@ipglider.org>2017-02-28 17:39:39 +0100
committerMiguel Herranz <miguel@ipglider.org>2017-02-28 17:39:39 +0100
commit1a7e18bfdfaeaadb33341173e09b614a129f07de (patch)
tree48059ce23f60b73f5c100b206ed07c532b2cb924 /src
parentMake get_random_gray_peer distribution uniform (diff)
downloadmonero-1a7e18bfdfaeaadb33341173e09b614a129f07de.tar.xz
Make gray peer selection uniform
Prevents the system from always picking the gray peers with the most recent last_seen.
Diffstat (limited to 'src')
-rw-r--r--src/p2p/net_node.inl9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index c40bd8c5d..99c4e9282 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -1023,7 +1023,14 @@ namespace nodetool
while(rand_count < (max_random_index+1)*3 && try_count < 10 && !m_net_server.is_stop_signal_sent())
{
++rand_count;
- size_t random_index = get_random_index_with_fixed_probability(max_random_index);
+ size_t random_index;
+
+ if (use_white_list) {
+ random_index = get_random_index_with_fixed_probability(max_random_index);
+ } else {
+ random_index = crypto::rand<size_t>() % m_peerlist.get_gray_peers_count();
+ }
+
CHECK_AND_ASSERT_MES(random_index < local_peers_count, false, "random_starter_index < peers_local.size() failed!!");
if(tried_peers.count(random_index))