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)
332332 info.nAttempts ++;
333333}
334334
335- CAddress CAddrMan::Select_ (int nUnkBias )
335+ CAddress CAddrMan::Select_ ()
336336{
337337 if (size () == 0 )
338338 return CAddress ();
339339
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 )) {
343342 // use a tried node
344343 double fChanceFactor = 1.0 ;
345344 while (1 ) {
Original file line number Diff line number Diff line change @@ -231,7 +231,7 @@ class CAddrMan
231231
232232 // ! Select an address to connect to.
233233 // ! nUnkBias determines how much to favor new addresses over tried ones (min=0, max=100)
234- CAddress Select_ (int nUnkBias );
234+ CAddress Select_ ();
235235
236236#ifdef DEBUG_ADDRMAN
237237 // ! Perform consistency check. Returns an error code or zero.
@@ -533,13 +533,13 @@ class CAddrMan
533533 * Choose an address to connect to.
534534 * nUnkBias determines how much "new" entries are favored over "tried" ones (0-100).
535535 */
536- CAddress Select (int nUnkBias = 50 )
536+ CAddress Select ()
537537 {
538538 CAddress addrRet;
539539 {
540540 LOCK (cs);
541541 Check ();
542- addrRet = Select_ (nUnkBias );
542+ addrRet = Select_ ();
543543 Check ();
544544 }
545545 return addrRet;
Original file line number Diff line number Diff line change @@ -1221,8 +1221,7 @@ void ThreadOpenConnections()
12211221 int nTries = 0 ;
12221222 while (true )
12231223 {
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 ();
12261225
12271226 // if we selected an invalid address, restart
12281227 if (!addr.IsValid () || setConnected.count (addr.GetGroup ()) || IsLocal (addr))
You can’t perform that action at this time.
0 commit comments