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.
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user