aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2020-09-12 18:17:49 +0300
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2020-10-09 14:29:05 +0300
commit5543c7ab285e90256cbbf9858249e028c9611cda (patch)
treeb935d00fb33e4e483ff406d9bc6617c7351974f9 /src/net.cpp
parent4170b46544231e7cf1d64ac3baa314083be37502 (diff)
p2p: Fix off-by-one error in fetching address loop
This is a move-only commit.
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 0fb4bf9bde..0fe06641e1 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -1962,6 +1962,13 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
int nTries = 0;
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();
// SelectTriedCollision returns an invalid address if it is empty.
@@ -1979,13 +1986,6 @@ void CConnman::ThreadOpenConnections(const std::vector<std::string> connect)
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))
continue;