@@ -221,7 +221,7 @@ void CAddrMan::Good_(const CService& addr, int64_t nTime)
221221 return ;
222222
223223 // find a bucket it is in now
224- int nRnd = GetRandInt (ADDRMAN_NEW_BUCKET_COUNT);
224+ int nRnd = RandomInt (ADDRMAN_NEW_BUCKET_COUNT);
225225 int nUBucket = -1 ;
226226 for (unsigned int n = 0 ; n < ADDRMAN_NEW_BUCKET_COUNT; n++) {
227227 int nB = (n + nRnd) % ADDRMAN_NEW_BUCKET_COUNT;
@@ -278,7 +278,7 @@ bool CAddrMan::Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimeP
278278 int nFactor = 1 ;
279279 for (int n = 0 ; n < pinfo->nRefCount ; n++)
280280 nFactor *= 2 ;
281- if (nFactor > 1 && (GetRandInt (nFactor) != 0 ))
281+ if (nFactor > 1 && (RandomInt (nFactor) != 0 ))
282282 return false ;
283283 } else {
284284 pinfo = Create (addr, source, &nId);
@@ -340,37 +340,37 @@ CAddrInfo CAddrMan::Select_(bool newOnly)
340340
341341 // Use a 50% chance for choosing between tried and new table entries.
342342 if (!newOnly &&
343- (nTried > 0 && (nNew == 0 || GetRandInt (2 ) == 0 ))) {
343+ (nTried > 0 && (nNew == 0 || RandomInt (2 ) == 0 ))) {
344344 // use a tried node
345345 double fChanceFactor = 1.0 ;
346346 while (1 ) {
347- int nKBucket = GetRandInt (ADDRMAN_TRIED_BUCKET_COUNT);
348- int nKBucketPos = GetRandInt (ADDRMAN_BUCKET_SIZE);
347+ int nKBucket = RandomInt (ADDRMAN_TRIED_BUCKET_COUNT);
348+ int nKBucketPos = RandomInt (ADDRMAN_BUCKET_SIZE);
349349 while (vvTried[nKBucket][nKBucketPos] == -1 ) {
350350 nKBucket = (nKBucket + insecure_rand ()) % ADDRMAN_TRIED_BUCKET_COUNT;
351351 nKBucketPos = (nKBucketPos + insecure_rand ()) % ADDRMAN_BUCKET_SIZE;
352352 }
353353 int nId = vvTried[nKBucket][nKBucketPos];
354354 assert (mapInfo.count (nId) == 1 );
355355 CAddrInfo& info = mapInfo[nId];
356- if (GetRandInt (1 << 30 ) < fChanceFactor * info.GetChance () * (1 << 30 ))
356+ if (RandomInt (1 << 30 ) < fChanceFactor * info.GetChance () * (1 << 30 ))
357357 return info;
358358 fChanceFactor *= 1.2 ;
359359 }
360360 } else {
361361 // use a new node
362362 double fChanceFactor = 1.0 ;
363363 while (1 ) {
364- int nUBucket = GetRandInt (ADDRMAN_NEW_BUCKET_COUNT);
365- int nUBucketPos = GetRandInt (ADDRMAN_BUCKET_SIZE);
364+ int nUBucket = RandomInt (ADDRMAN_NEW_BUCKET_COUNT);
365+ int nUBucketPos = RandomInt (ADDRMAN_BUCKET_SIZE);
366366 while (vvNew[nUBucket][nUBucketPos] == -1 ) {
367367 nUBucket = (nUBucket + insecure_rand ()) % ADDRMAN_NEW_BUCKET_COUNT;
368368 nUBucketPos = (nUBucketPos + insecure_rand ()) % ADDRMAN_BUCKET_SIZE;
369369 }
370370 int nId = vvNew[nUBucket][nUBucketPos];
371371 assert (mapInfo.count (nId) == 1 );
372372 CAddrInfo& info = mapInfo[nId];
373- if (GetRandInt (1 << 30 ) < fChanceFactor * info.GetChance () * (1 << 30 ))
373+ if (RandomInt (1 << 30 ) < fChanceFactor * info.GetChance () * (1 << 30 ))
374374 return info;
375375 fChanceFactor *= 1.2 ;
376376 }
@@ -466,7 +466,7 @@ void CAddrMan::GetAddr_(std::vector<CAddress>& vAddr)
466466 if (vAddr.size () >= nNodes)
467467 break ;
468468
469- int nRndPos = GetRandInt (vRandom.size () - n) + n;
469+ int nRndPos = RandomInt (vRandom.size () - n) + n;
470470 SwapRandom (n, nRndPos);
471471 assert (mapInfo.count (vRandom[n]) == 1 );
472472
@@ -495,3 +495,7 @@ void CAddrMan::Connected_(const CService& addr, int64_t nTime)
495495 if (nTime - info.nTime > nUpdateInterval)
496496 info.nTime = nTime;
497497}
498+
499+ int CAddrMan::RandomInt (int nMax){
500+ return GetRandInt (nMax);
501+ }
0 commit comments