Merge pull request #6028
1d5b47a
nLastTry is only used for addrman entries (Pieter Wuille)
This commit is contained in:
commit
b9311fb631
@ -331,10 +331,10 @@ void CAddrMan::Attempt_(const CService& addr, int64_t nTime)
|
|||||||
info.nAttempts++;
|
info.nAttempts++;
|
||||||
}
|
}
|
||||||
|
|
||||||
CAddress CAddrMan::Select_()
|
CAddrInfo CAddrMan::Select_()
|
||||||
{
|
{
|
||||||
if (size() == 0)
|
if (size() == 0)
|
||||||
return CAddress();
|
return CAddrInfo();
|
||||||
|
|
||||||
// Use a 50% chance for choosing between tried and new table entries.
|
// Use a 50% chance for choosing between tried and new table entries.
|
||||||
if (nTried > 0 && (nNew == 0 || GetRandInt(2) == 0)) {
|
if (nTried > 0 && (nNew == 0 || GetRandInt(2) == 0)) {
|
||||||
|
@ -22,6 +22,10 @@
|
|||||||
*/
|
*/
|
||||||
class CAddrInfo : public CAddress
|
class CAddrInfo : public CAddress
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
//! last try whatsoever by us (memory only)
|
||||||
|
int64_t nLastTry;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! where knowledge about this address first came from
|
//! where knowledge about this address first came from
|
||||||
CNetAddr source;
|
CNetAddr source;
|
||||||
@ -29,9 +33,6 @@ private:
|
|||||||
//! last successful connection by us
|
//! last successful connection by us
|
||||||
int64_t nLastSuccess;
|
int64_t nLastSuccess;
|
||||||
|
|
||||||
//! last try whatsoever by us:
|
|
||||||
// int64_t CAddress::nLastTry
|
|
||||||
|
|
||||||
//! connection attempts since last successful attempt
|
//! connection attempts since last successful attempt
|
||||||
int nAttempts;
|
int nAttempts;
|
||||||
|
|
||||||
@ -231,7 +232,7 @@ protected:
|
|||||||
|
|
||||||
//! Select an address to connect to.
|
//! Select an address to connect to.
|
||||||
//! nUnkBias determines how much to favor new addresses over tried ones (min=0, max=100)
|
//! nUnkBias determines how much to favor new addresses over tried ones (min=0, max=100)
|
||||||
CAddress Select_();
|
CAddrInfo Select_();
|
||||||
|
|
||||||
#ifdef DEBUG_ADDRMAN
|
#ifdef DEBUG_ADDRMAN
|
||||||
//! Perform consistency check. Returns an error code or zero.
|
//! Perform consistency check. Returns an error code or zero.
|
||||||
@ -533,9 +534,9 @@ public:
|
|||||||
* Choose an address to connect to.
|
* Choose an address to connect to.
|
||||||
* nUnkBias determines how much "new" entries are favored over "tried" ones (0-100).
|
* nUnkBias determines how much "new" entries are favored over "tried" ones (0-100).
|
||||||
*/
|
*/
|
||||||
CAddress Select()
|
CAddrInfo Select()
|
||||||
{
|
{
|
||||||
CAddress addrRet;
|
CAddrInfo addrRet;
|
||||||
{
|
{
|
||||||
LOCK(cs);
|
LOCK(cs);
|
||||||
Check();
|
Check();
|
||||||
|
@ -1221,7 +1221,7 @@ void ThreadOpenConnections()
|
|||||||
int nTries = 0;
|
int nTries = 0;
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
CAddress addr = addrman.Select();
|
CAddrInfo addr = addrman.Select();
|
||||||
|
|
||||||
// if we selected an invalid address, restart
|
// if we selected an invalid address, restart
|
||||||
if (!addr.IsValid() || setConnected.count(addr.GetGroup()) || IsLocal(addr))
|
if (!addr.IsValid() || setConnected.count(addr.GetGroup()) || IsLocal(addr))
|
||||||
|
@ -89,7 +89,6 @@ void CAddress::Init()
|
|||||||
{
|
{
|
||||||
nServices = NODE_NETWORK;
|
nServices = NODE_NETWORK;
|
||||||
nTime = 100000000;
|
nTime = 100000000;
|
||||||
nLastTry = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CInv::CInv()
|
CInv::CInv()
|
||||||
|
@ -116,9 +116,6 @@ public:
|
|||||||
|
|
||||||
// disk and network only
|
// disk and network only
|
||||||
unsigned int nTime;
|
unsigned int nTime;
|
||||||
|
|
||||||
// memory only
|
|
||||||
int64_t nLastTry;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/** inv message data */
|
/** inv message data */
|
||||||
|
Loading…
Reference in New Issue
Block a user