@@ -224,7 +224,7 @@ void CAddrMan::Good_(const CService& addr, int64_t nTime)
224
224
return ;
225
225
226
226
// find a bucket it is in now
227
- int nRnd = GetRandInt (ADDRMAN_NEW_BUCKET_COUNT);
227
+ int nRnd = RandomInt (ADDRMAN_NEW_BUCKET_COUNT);
228
228
int nUBucket = -1 ;
229
229
for (unsigned int n = 0 ; n < ADDRMAN_NEW_BUCKET_COUNT; n++) {
230
230
int nB = (n + nRnd) % ADDRMAN_NEW_BUCKET_COUNT;
@@ -281,7 +281,7 @@ bool CAddrMan::Add_(const CAddress& addr, const CNetAddr& source, int64_t nTimeP
281
281
int nFactor = 1 ;
282
282
for (int n = 0 ; n < pinfo->nRefCount ; n++)
283
283
nFactor *= 2 ;
284
- if (nFactor > 1 && (GetRandInt (nFactor) != 0 ))
284
+ if (nFactor > 1 && (RandomInt (nFactor) != 0 ))
285
285
return false ;
286
286
} else {
287
287
pinfo = Create (addr, source, &nId);
@@ -342,37 +342,37 @@ CAddrInfo CAddrMan::Select_(bool newOnly)
342
342
return CAddrInfo ();
343
343
344
344
// Use a 50% chance for choosing between tried and new table entries.
345
- if (!newOnly && (nTried > 0 && (nNew == 0 || GetRandInt (2 ) == 0 ))) {
345
+ if (!newOnly && (nTried > 0 && (nNew == 0 || RandomInt (2 ) == 0 ))) {
346
346
// use a tried node
347
347
double fChanceFactor = 1.0 ;
348
348
while (1 ) {
349
- int nKBucket = GetRandInt (ADDRMAN_TRIED_BUCKET_COUNT);
350
- int nKBucketPos = GetRandInt (ADDRMAN_BUCKET_SIZE);
349
+ int nKBucket = RandomInt (ADDRMAN_TRIED_BUCKET_COUNT);
350
+ int nKBucketPos = RandomInt (ADDRMAN_BUCKET_SIZE);
351
351
while (vvTried[nKBucket][nKBucketPos] == -1 ) {
352
352
nKBucket = (nKBucket + insecure_rand ()) % ADDRMAN_TRIED_BUCKET_COUNT;
353
353
nKBucketPos = (nKBucketPos + insecure_rand ()) % ADDRMAN_BUCKET_SIZE;
354
354
}
355
355
int nId = vvTried[nKBucket][nKBucketPos];
356
356
assert (mapInfo.count (nId) == 1 );
357
357
CAddrInfo& info = mapInfo[nId];
358
- if (GetRandInt (1 << 30 ) < fChanceFactor * info.GetChance () * (1 << 30 ))
358
+ if (RandomInt (1 << 30 ) < fChanceFactor * info.GetChance () * (1 << 30 ))
359
359
return info;
360
360
fChanceFactor *= 1.2 ;
361
361
}
362
362
} else {
363
363
// use a new node
364
364
double fChanceFactor = 1.0 ;
365
365
while (1 ) {
366
- int nUBucket = GetRandInt (ADDRMAN_NEW_BUCKET_COUNT);
367
- int nUBucketPos = GetRandInt (ADDRMAN_BUCKET_SIZE);
366
+ int nUBucket = RandomInt (ADDRMAN_NEW_BUCKET_COUNT);
367
+ int nUBucketPos = RandomInt (ADDRMAN_BUCKET_SIZE);
368
368
while (vvNew[nUBucket][nUBucketPos] == -1 ) {
369
369
nUBucket = (nUBucket + insecure_rand ()) % ADDRMAN_NEW_BUCKET_COUNT;
370
370
nUBucketPos = (nUBucketPos + insecure_rand ()) % ADDRMAN_BUCKET_SIZE;
371
371
}
372
372
int nId = vvNew[nUBucket][nUBucketPos];
373
373
assert (mapInfo.count (nId) == 1 );
374
374
CAddrInfo& info = mapInfo[nId];
375
- if (GetRandInt (1 << 30 ) < fChanceFactor * info.GetChance () * (1 << 30 ))
375
+ if (RandomInt (1 << 30 ) < fChanceFactor * info.GetChance () * (1 << 30 ))
376
376
return info;
377
377
fChanceFactor *= 1.2 ;
378
378
}
@@ -468,7 +468,7 @@ void CAddrMan::GetAddr_(std::vector<CAddress>& vAddr)
468
468
if (vAddr.size () >= nNodes)
469
469
break ;
470
470
471
- int nRndPos = GetRandInt (vRandom.size () - n) + n;
471
+ int nRndPos = RandomInt (vRandom.size () - n) + n;
472
472
SwapRandom (n, nRndPos);
473
473
assert (mapInfo.count (vRandom[n]) == 1 );
474
474
@@ -497,3 +497,7 @@ void CAddrMan::Connected_(const CService& addr, int64_t nTime)
497
497
if (nTime - info.nTime > nUpdateInterval)
498
498
info.nTime = nTime;
499
499
}
500
+
501
+ int CAddrMan::RandomInt (int nMax){
502
+ return GetRandInt (nMax);
503
+ }
0 commit comments