reduced CPU load at floodfill

This commit is contained in:
orignal 2015-04-10 18:13:11 -04:00
parent 2a997d94bf
commit 9072a018dd

View file

@ -704,13 +704,15 @@ namespace data
if (!replyMsg) if (!replyMsg)
{ {
LogPrint ("Requested ", key, " not found. ", numExcluded, " excluded"); LogPrint ("Requested ", key, " not found. ", numExcluded, " excluded");
std::vector<IdentHash> routers;
if (numExcluded > 0)
{
std::set<IdentHash> excludedRouters; std::set<IdentHash> excludedRouters;
for (int i = 0; i < numExcluded; i++) for (int i = 0; i < numExcluded; i++)
{ {
excludedRouters.insert (excluded); excludedRouters.insert (excluded);
excluded += 32; excluded += 32;
} }
std::vector<IdentHash> routers;
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
{ {
auto floodfill = GetClosestFloodfill (buf, excludedRouters); auto floodfill = GetClosestFloodfill (buf, excludedRouters);
@ -720,6 +722,9 @@ namespace data
excludedRouters.insert (floodfill->GetIdentHash ()); excludedRouters.insert (floodfill->GetIdentHash ());
} }
} }
}
else
routers = GetClosestFloodfills (buf, 3);
replyMsg = CreateDatabaseSearchReply (buf, routers); replyMsg = CreateDatabaseSearchReply (buf, routers);
} }
} }