aboutsummaryrefslogtreecommitdiff
path: root/src/addrman.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2016-06-08 12:58:21 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2016-06-08 13:01:53 +0200
commit67c91f8c4cf738376f8b92429151494032bf9f91 (patch)
tree006d2121a7572a53c1cc8ceb943886e3bdde88c3 /src/addrman.h
parent2156fa23b8ac95283a8b11432607aaffaabd2953 (diff)
parent6182d10503ae3af222a7e4575724dce7ef563fec (diff)
downloadbitcoin-67c91f8c4cf738376f8b92429151494032bf9f91.tar.xz
Merge #8065: Addrman offline attempts
6182d10 Do not increment nAttempts by more than one for every Good connection. (Gregory Maxwell) c769c4a Avoid counting failed connect attempts when probably offline. (Gregory Maxwell)
Diffstat (limited to 'src/addrman.h')
-rw-r--r--src/addrman.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/addrman.h b/src/addrman.h
index 3085450450..c5923e9417 100644
--- a/src/addrman.h
+++ b/src/addrman.h
@@ -29,6 +29,9 @@ public:
//! last try whatsoever by us (memory only)
int64_t nLastTry;
+ //! last counted attempt (memory only)
+ int64_t nLastCountAttempt;
+
private:
//! where knowledge about this address first came from
CNetAddr source;
@@ -66,6 +69,7 @@ public:
{
nLastSuccess = 0;
nLastTry = 0;
+ nLastCountAttempt = 0;
nAttempts = 0;
nRefCount = 0;
fInTried = false;
@@ -200,6 +204,9 @@ private:
//! list of "new" buckets
int vvNew[ADDRMAN_NEW_BUCKET_COUNT][ADDRMAN_BUCKET_SIZE];
+ //! last time Good was called (memory only)
+ int64_t nLastGood;
+
protected:
//! secret key to randomize bucket select with
uint256 nKey;
@@ -230,7 +237,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);
@@ -458,6 +465,7 @@ public:
nIdCount = 0;
nTried = 0;
nNew = 0;
+ nLastGood = 1; //Initially at 1 so that "never" is strictly worse.
}
CAddrMan()
@@ -532,12 +540,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();
}
}