Skip to content

Commit

Permalink
[addrman] Ensure collisions eventually get resolved
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
sdaftuar committed Feb 27, 2019
1 parent 4991e3c commit f71fdda
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/addrman.cpp
Expand Up @@ -569,6 +569,13 @@ void CAddrMan::ResolveCollisions_()
Good_(info_new, false, GetAdjustedTime());
erase_collision = true;
}
} else if (GetAdjustedTime() - info_new.nLastSuccess > ADDRMAN_TEST_WINDOW) {
// If the collision hasn't resolved in some reasonable amount of time,
// just evict the old entry -- we must not be able to
// connect to it for some reason.
LogPrint(BCLog::ADDRMAN, "Unable to test; swapping %s for %s in tried table anyway\n", info_new.ToString(), info_old.ToString());
Good_(info_new, false, GetAdjustedTime());
erase_collision = true;
}
} else { // Collision is not actually a collision anymore
Good_(info_new, false, GetAdjustedTime());
Expand Down
3 changes: 3 additions & 0 deletions src/addrman.h
Expand Up @@ -166,6 +166,9 @@ class CAddrInfo : public CAddress
//! the maximum number of tried addr collisions to store
#define ADDRMAN_SET_TRIED_COLLISION_SIZE 10

//! the maximum time we'll spend trying to resolve a tried table collision, in seconds
static const int64_t ADDRMAN_TEST_WINDOW = 40*60; // 40 minutes

/**
* Stochastical (IP) address manager
*/
Expand Down

0 comments on commit f71fdda

Please sign in to comment.