diff options
author | Suhas Daftuar <sdaftuar@gmail.com> | 2019-02-26 16:34:26 -0500 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2019-03-09 07:13:26 +0100 |
commit | 333be7aabf0b8e6f64dbc8fe141d0aa18dcb6f41 (patch) | |
tree | 68f2b9248fed538a790b0b8e6968c29a9f3e1459 | |
parent | 487f0c3dc92285bb4388c86c03c2caafe26171c4 (diff) |
[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.
Github-Pull: #15486
Rebased-From: f71fdda3bc2e7acd2a8b74e882364866b8b0f55b
Tree-SHA512: 66c61a9f030b1666e98e4fe66dd6cfc5f1d03b2a1ec01567b195903db6e4412ac778f4464ee9ef35ae6faa1ab7e4b18ef7ecb9a7ced29e6494046990aebf7b76
-rw-r--r-- | src/addrman.cpp | 7 | ||||
-rw-r--r-- | src/addrman.h | 3 |
2 files changed, 10 insertions, 0 deletions
diff --git a/src/addrman.cpp b/src/addrman.cpp index 468618095c..45b686e1de 100644 --- a/src/addrman.cpp +++ b/src/addrman.cpp @@ -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()); diff --git a/src/addrman.h b/src/addrman.h index 003bd059f8..e54184ce35 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -166,6 +166,9 @@ public: //! 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 */ |