aboutsummaryrefslogtreecommitdiff
path: root/src/p2p/net_peerlist.h
diff options
context:
space:
mode:
authorstoffu <stoffu@protonmail.ch>2019-04-03 14:10:24 +0900
committerstoffu <stoffu@protonmail.ch>2019-04-04 22:38:19 +0900
commita2195b9b7fba5da7f47903961db3fb31f6d7146c (patch)
treed467a2e82b12cb0b6945c91bcef5f93bd8a93746 /src/p2p/net_peerlist.h
parentMerge pull request #5319 (diff)
downloadmonero-a2195b9b7fba5da7f47903961db3fb31f6d7146c.tar.xz
crypto: replace rand<T>()%N idiom with unbiased rand_idx(N)
Diffstat (limited to '')
-rw-r--r--src/p2p/net_peerlist.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/p2p/net_peerlist.h b/src/p2p/net_peerlist.h
index ebe0268d8..52814af94 100644
--- a/src/p2p/net_peerlist.h
+++ b/src/p2p/net_peerlist.h
@@ -398,7 +398,7 @@ namespace nodetool
return false;
}
- size_t random_index = crypto::rand<size_t>() % m_peers_gray.size();
+ size_t random_index = crypto::rand_idx(m_peers_gray.size());
peers_indexed::index<by_time>::type& by_time_index = m_peers_gray.get<by_time>();
pe = *epee::misc_utils::move_it_backward(--by_time_index.end(), random_index);