mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-08 10:31:50 -05:00
p2p: Fix off-by-one error in fetching address loop
This is a move-only commit.
This commit is contained in:
parent
4170b46544
commit
5543c7ab28
1 changed files with 7 additions and 7 deletions
14
src/net.cpp
14
src/net.cpp
|
@ -1962,6 +1962,13 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
|
||||||
int nTries = 0;
|
int nTries = 0;
|
||||||
while (!interruptNet)
|
while (!interruptNet)
|
||||||
{
|
{
|
||||||
|
// If we didn't find an appropriate destination after trying 100 addresses fetched from addrman,
|
||||||
|
// stop this loop, and let the outer loop run again (which sleeps, adds seed nodes, recalculates
|
||||||
|
// already-connected network ranges, ...) before trying new addrman addresses.
|
||||||
|
nTries++;
|
||||||
|
if (nTries > 100)
|
||||||
|
break;
|
||||||
|
|
||||||
CAddrInfo addr = addrman.SelectTriedCollision();
|
CAddrInfo addr = addrman.SelectTriedCollision();
|
||||||
|
|
||||||
// SelectTriedCollision returns an invalid address if it is empty.
|
// SelectTriedCollision returns an invalid address if it is empty.
|
||||||
|
@ -1979,13 +1986,6 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we didn't find an appropriate destination after trying 100 addresses fetched from addrman,
|
|
||||||
// stop this loop, and let the outer loop run again (which sleeps, adds seed nodes, recalculates
|
|
||||||
// already-connected network ranges, ...) before trying new addrman addresses.
|
|
||||||
nTries++;
|
|
||||||
if (nTries > 100)
|
|
||||||
break;
|
|
||||||
|
|
||||||
if (!IsReachable(addr))
|
if (!IsReachable(addr))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue