diff options
author | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-01-18 16:54:52 +0000 |
---|---|---|
committer | moneromooo-monero <moneromooo-monero@users.noreply.github.com> | 2018-01-18 17:11:37 +0000 |
commit | ab58b150ef5e41aae31f4f2af35427d45a8cc151 (patch) | |
tree | 9e0055298f04f17009edae9c62f5507a1eb159de | |
parent | Merge pull request #3091 (diff) | |
download | monero-ab58b150ef5e41aae31f4f2af35427d45a8cc151.tar.xz |
p2p: fix picking peers off an empty gray list
-rw-r--r-- | src/p2p/net_node.inl | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index 269a9ba87..f8b96d7a4 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -1062,7 +1062,10 @@ namespace nodetool max_random_index = std::min<uint64_t>(local_peers_count -1, 20); random_index = get_random_index_with_fixed_probability(max_random_index); } else { - random_index = crypto::rand<size_t>() % m_peerlist.get_gray_peers_count(); + local_peers_count = m_peerlist.get_gray_peers_count(); + if (!local_peers_count) + return false; + random_index = crypto::rand<size_t>() % local_peers_count; } CHECK_AND_ASSERT_MES(random_index < local_peers_count, false, "random_starter_index < peers_local.size() failed!!"); |