Skip to content

Commit

Permalink
Merge pull request #6028
Browse files Browse the repository at this point in the history
1d5b47a nLastTry is only used for addrman entries (Pieter Wuille)
  • Loading branch information
laanwj committed Apr 24, 2015
2 parents 585b5db + 1d5b47a commit b9311fb
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/addrman.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -331,10 +331,10 @@ void CAddrMan::Attempt_(const CService& addr, int64_t nTime)
info.nAttempts++;
}

CAddress CAddrMan::Select_()
CAddrInfo CAddrMan::Select_()
{
if (size() == 0)
return CAddress();
return CAddrInfo();

// Use a 50% chance for choosing between tried and new table entries.
if (nTried > 0 && (nNew == 0 || GetRandInt(2) == 0)) {
Expand Down
13 changes: 7 additions & 6 deletions src/addrman.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,17 @@
*/
class CAddrInfo : public CAddress
{
public:
//! last try whatsoever by us (memory only)
int64_t nLastTry;

private:
//! where knowledge about this address first came from
CNetAddr source;

//! last successful connection by us
int64_t nLastSuccess;

//! last try whatsoever by us:
// int64_t CAddress::nLastTry

//! connection attempts since last successful attempt
int nAttempts;

Expand Down Expand Up @@ -231,7 +232,7 @@ class CAddrMan

//! Select an address to connect to.
//! nUnkBias determines how much to favor new addresses over tried ones (min=0, max=100)
CAddress Select_();
CAddrInfo Select_();

#ifdef DEBUG_ADDRMAN
//! Perform consistency check. Returns an error code or zero.
Expand Down Expand Up @@ -533,9 +534,9 @@ class CAddrMan
* Choose an address to connect to.
* nUnkBias determines how much "new" entries are favored over "tried" ones (0-100).
*/
CAddress Select()
CAddrInfo Select()
{
CAddress addrRet;
CAddrInfo addrRet;
{
LOCK(cs);
Check();
Expand Down
2 changes: 1 addition & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1221,7 +1221,7 @@ void ThreadOpenConnections()
int nTries = 0;
while (true)
{
CAddress addr = addrman.Select();
CAddrInfo addr = addrman.Select();

// if we selected an invalid address, restart
if (!addr.IsValid() || setConnected.count(addr.GetGroup()) || IsLocal(addr))
Expand Down
1 change: 0 additions & 1 deletion src/protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ void CAddress::Init()
{
nServices = NODE_NETWORK;
nTime = 100000000;
nLastTry = 0;
}

CInv::CInv()
Expand Down
3 changes: 0 additions & 3 deletions src/protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ class CAddress : public CService

// disk and network only
unsigned int nTime;

// memory only
int64_t nLastTry;
};

/** inv message data */
Expand Down

0 comments on commit b9311fb

Please sign in to comment.