Add a FastRandomContext::randrange and use it

This commit is contained in:
Pieter Wuille
2017-02-25 12:16:58 -08:00
parent 16329224e7
commit 4fd2d2fc97
7 changed files with 75 additions and 2 deletions

View File

@@ -760,7 +760,7 @@ public:
// after addresses were pushed.
if (_addr.IsValid() && !addrKnown.contains(_addr.GetKey())) {
if (vAddrToSend.size() >= MAX_ADDR_TO_SEND) {
vAddrToSend[insecure_rand.rand32() % vAddrToSend.size()] = _addr;
vAddrToSend[insecure_rand.randrange(vAddrToSend.size())] = _addr;
} else {
vAddrToSend.push_back(_addr);
}