diff options
author | stoffu <stoffu@protonmail.ch> | 2019-04-03 14:10:24 +0900 |
---|---|---|
committer | stoffu <stoffu@protonmail.ch> | 2019-04-04 22:38:19 +0900 |
commit | a2195b9b7fba5da7f47903961db3fb31f6d7146c (patch) | |
tree | d467a2e82b12cb0b6945c91bcef5f93bd8a93746 /src/p2p/net_node.inl | |
parent | Merge pull request #5319 (diff) | |
download | monero-a2195b9b7fba5da7f47903961db3fb31f6d7146c.tar.xz |
crypto: replace rand<T>()%N idiom with unbiased rand_idx(N)
Diffstat (limited to 'src/p2p/net_node.inl')
-rw-r--r-- | src/p2p/net_node.inl | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl index f0aef384f..7d13b3216 100644 --- a/src/p2p/net_node.inl +++ b/src/p2p/net_node.inl @@ -1259,7 +1259,7 @@ namespace nodetool } } else - random_index = crypto::rand<size_t>() % filtered.size(); + random_index = crypto::rand_idx(filtered.size()); CHECK_AND_ASSERT_MES(random_index < filtered.size(), false, "random_index < filtered.size() failed!!"); random_index = filtered[random_index]; @@ -1313,7 +1313,7 @@ namespace nodetool return true; size_t try_count = 0; - size_t current_index = crypto::rand<size_t>()%m_seed_nodes.size(); + size_t current_index = crypto::rand_idx(m_seed_nodes.size()); const net_server& server = m_network_zones.at(epee::net_utils::zone::public_).m_net_server; while(true) { |