Skip to content

Commit 5543c7a

Browse files
committed
p2p: Fix off-by-one error in fetching address loop
This is a move-only commit.
1 parent 4170b46 commit 5543c7a

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/net.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1962,6 +1962,13 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
19621962
int nTries = 0;
19631963
while (!interruptNet)
19641964
{
1965+
// If we didn't find an appropriate destination after trying 100 addresses fetched from addrman,
1966+
// stop this loop, and let the outer loop run again (which sleeps, adds seed nodes, recalculates
1967+
// already-connected network ranges, ...) before trying new addrman addresses.
1968+
nTries++;
1969+
if (nTries > 100)
1970+
break;
1971+
19651972
CAddrInfo addr = addrman.SelectTriedCollision();
19661973

19671974
// SelectTriedCollision returns an invalid address if it is empty.
@@ -1979,13 +1986,6 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
19791986
break;
19801987
}
19811988

1982-
// If we didn't find an appropriate destination after trying 100 addresses fetched from addrman,
1983-
// stop this loop, and let the outer loop run again (which sleeps, adds seed nodes, recalculates
1984-
// already-connected network ranges, ...) before trying new addrman addresses.
1985-
nTries++;
1986-
if (nTries > 100)
1987-
break;
1988-
19891989
if (!IsReachable(addr))
19901990
continue;
19911991

0 commit comments

Comments
 (0)