add additional case (#1180)

* add additional case for if we are near the end and all elements are in the exlcude set

* fix stop condition in second loop
pull/1168/head
Jeff 4 years ago committed by GitHub
parent c19c83a442
commit 3f4b2a53fa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -539,7 +539,16 @@ llarp_nodedb::select_random_hop_excluding(
}
const size_t pos = llarp::randint() % sz;
for(auto itr = std::next(entries.begin(), pos); itr != entries.end(); ++itr)
const auto start = std::next(entries.begin(), pos);
for(auto itr = start; itr != entries.end(); ++itr)
{
if(exclude.count(itr->first) == 0 and itr->second.rc.IsPublicRouter())
{
result = itr->second.rc;
return true;
}
}
for(auto itr = entries.begin(); itr != start; ++itr)
{
if(exclude.count(itr->first) == 0 and itr->second.rc.IsPublicRouter())
{

Loading…
Cancel
Save