diff options
author | Gregory Maxwell <greg@xiph.org> | 2015-04-19 12:34:43 -0700 |
---|---|---|
committer | Gregory Maxwell <greg@xiph.org> | 2016-05-26 12:56:27 +0000 |
commit | c769c4af11fc58dd4813d328c7f71042bc577676 (patch) | |
tree | 7c86c072c97dd185d723cc1bac363a3c34b000ff /src/addrman.h | |
parent | f6b7df3155ddb4cedfbcf5d3eb3383d4614b3a85 (diff) |
Avoid counting failed connect attempts when probably offline.
If a node is offline failed outbound connection attempts will crank up
the addrman counter and effectively blow away our state.
This change reduces the problem by only counting attempts made while
the node believes it has outbound connections to at least two
netgroups.
Connect and addnode connections are also not counted, as there is no
reason to unequally penalize them for their more frequent
connections -- though there should be no real effect from this
unless their addnode configureation is later removed.
Wasteful repeated connection attempts while only a few connections are
up are avoided via nLastTry.
This is still somewhat incomplete protection because our outbound
peers could be down but not timed out or might all be on 'local'
networks (although the requirement for multiple netgroups helps).
Diffstat (limited to 'src/addrman.h')
-rw-r--r-- | src/addrman.h | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/addrman.h b/src/addrman.h index 3085450450..65ca79fa02 100644 --- a/src/addrman.h +++ b/src/addrman.h @@ -230,7 +230,7 @@ protected: bool Add_(const CAddress &addr, const CNetAddr& source, int64_t nTimePenalty); //! Mark an entry as attempted to connect. - void Attempt_(const CService &addr, int64_t nTime); + void Attempt_(const CService &addr, bool fCountFailure, int64_t nTime); //! Select an address to connect to, if newOnly is set to true, only the new table is selected from. CAddrInfo Select_(bool newOnly); @@ -532,12 +532,12 @@ public: } //! Mark an entry as connection attempted to. - void Attempt(const CService &addr, int64_t nTime = GetAdjustedTime()) + void Attempt(const CService &addr, bool fCountFailure, int64_t nTime = GetAdjustedTime()) { { LOCK(cs); Check(); - Attempt_(addr, nTime); + Attempt_(addr, fCountFailure, nTime); Check(); } } |