File tree Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Expand file tree Collapse file tree 3 files changed +7
-9
lines changed Original file line number Diff line number Diff line change @@ -332,14 +332,13 @@ void CAddrMan::Attempt_(const CService& addr, int64_t nTime)
332
332
info.nAttempts ++;
333
333
}
334
334
335
- CAddress CAddrMan::Select_ (int nUnkBias )
335
+ CAddress CAddrMan::Select_ ()
336
336
{
337
337
if (size () == 0 )
338
338
return CAddress ();
339
339
340
- double nCorTried = sqrt (nTried) * (100.0 - nUnkBias);
341
- double nCorNew = sqrt (nNew) * nUnkBias;
342
- if ((nCorTried + nCorNew) * GetRandInt (1 << 30 ) / (1 << 30 ) < nCorTried) {
340
+ // Use a 50% chance for choosing between tried and new table entries.
341
+ if (nTried > 0 && (nNew == 0 || GetRandInt (2 ) == 0 )) {
343
342
// use a tried node
344
343
double fChanceFactor = 1.0 ;
345
344
while (1 ) {
Original file line number Diff line number Diff line change @@ -231,7 +231,7 @@ class CAddrMan
231
231
232
232
// ! Select an address to connect to.
233
233
// ! nUnkBias determines how much to favor new addresses over tried ones (min=0, max=100)
234
- CAddress Select_ (int nUnkBias );
234
+ CAddress Select_ ();
235
235
236
236
#ifdef DEBUG_ADDRMAN
237
237
// ! Perform consistency check. Returns an error code or zero.
@@ -533,13 +533,13 @@ class CAddrMan
533
533
* Choose an address to connect to.
534
534
* nUnkBias determines how much "new" entries are favored over "tried" ones (0-100).
535
535
*/
536
- CAddress Select (int nUnkBias = 50 )
536
+ CAddress Select ()
537
537
{
538
538
CAddress addrRet;
539
539
{
540
540
LOCK (cs);
541
541
Check ();
542
- addrRet = Select_ (nUnkBias );
542
+ addrRet = Select_ ();
543
543
Check ();
544
544
}
545
545
return addrRet;
Original file line number Diff line number Diff line change @@ -1221,8 +1221,7 @@ void ThreadOpenConnections()
1221
1221
int nTries = 0 ;
1222
1222
while (true )
1223
1223
{
1224
- // use an nUnkBias between 10 (no outgoing connections) and 90 (8 outgoing connections)
1225
- CAddress addr = addrman.Select (10 + min (nOutbound,8 )*10 );
1224
+ CAddress addr = addrman.Select ();
1226
1225
1227
1226
// if we selected an invalid address, restart
1228
1227
if (!addr.IsValid () || setConnected.count (addr.GetGroup ()) || IsLocal (addr))
You can’t perform that action at this time.
0 commit comments