Skip to content

Commit f71fdda

Browse files
committed
[addrman] Ensure collisions eventually get resolved
After 40 minutes, time out a test-before-evict entry and just evict without testing. Otherwise, if we were unable to test an entry for some reason, we might break using feelers altogether.
1 parent 4991e3c commit f71fdda

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/addrman.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,13 @@ void CAddrMan::ResolveCollisions_()
569569
Good_(info_new, false, GetAdjustedTime());
570570
erase_collision = true;
571571
}
572+
} else if (GetAdjustedTime() - info_new.nLastSuccess > ADDRMAN_TEST_WINDOW) {
573+
// If the collision hasn't resolved in some reasonable amount of time,
574+
// just evict the old entry -- we must not be able to
575+
// connect to it for some reason.
576+
LogPrint(BCLog::ADDRMAN, "Unable to test; swapping %s for %s in tried table anyway\n", info_new.ToString(), info_old.ToString());
577+
Good_(info_new, false, GetAdjustedTime());
578+
erase_collision = true;
572579
}
573580
} else { // Collision is not actually a collision anymore
574581
Good_(info_new, false, GetAdjustedTime());

src/addrman.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,9 @@ class CAddrInfo : public CAddress
166166
//! the maximum number of tried addr collisions to store
167167
#define ADDRMAN_SET_TRIED_COLLISION_SIZE 10
168168

169+
//! the maximum time we'll spend trying to resolve a tried table collision, in seconds
170+
static const int64_t ADDRMAN_TEST_WINDOW = 40*60; // 40 minutes
171+
169172
/**
170173
* Stochastical (IP) address manager
171174
*/

0 commit comments

Comments
 (0)