Browse Source

Try to prevent #266

We seem to have a bug that we don't find a peer when looking for a peer
in peers.dat . Instead of doing an assertion and crashing the node,
just keep iterating in the loop. The code which computes nId may have an
off-by-one error, such that it looks up an incorrect bucket position and
doesn't find a valid nId.
pull/305/head
Duke 1 year ago
parent
commit
7102d50a47
  1. 14
      src/addrman.cpp

14
src/addrman.cpp

@ -499,7 +499,12 @@ CAddrInfo CAddrMan::Select_(bool newOnly)
MilliSleep(kRetrySleepInterval);
}
int nId = vvTried[nKBucket][nKBucketPos];
assert(mapInfo.count(nId) == 1);
// assert(mapInfo.count(nId) == 1);
if(mapInfo.count(nId) != 1) {
fprintf(stderr,"%s: Could not find tried node with nId=%d=vvTried[%d][%d], mapInfo.count(%d)=%d\n", __func__, nId, nKBucket, nKBuckedPos, nId, mapInfo.count(nId) );
continue;
}
CAddrInfo& info = mapInfo[nId];
if (info.IsReachableNetwork()) {
//deprioritize unreachable networks
@ -534,7 +539,12 @@ CAddrInfo CAddrMan::Select_(bool newOnly)
MilliSleep(kRetrySleepInterval);
}
int nId = vvNew[nUBucket][nUBucketPos];
assert(mapInfo.count(nId) == 1);
if(mapInfo.count(nId) != 1) {
fprintf(stderr,"%s: Could not find new node with nId=%d=vvNew[%d][%d], mapInfo.count(%d)=%d\n", __func__, nId, nUBucket, nUBuckedPos, nId, mapInfo.count(nId) );
continue;
}
// assert(mapInfo.count(nId) == 1);
CAddrInfo& info = mapInfo[nId];
if (info.IsReachableNetwork()) {
//deprioritize unreachable networks

Loading…
Cancel
Save