|
|
@ -732,28 +732,13 @@ namespace data |
|
|
|
if (!replyMsg) |
|
|
|
if (!replyMsg) |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrint ("Requested ", key, " not found. ", numExcluded, " excluded"); |
|
|
|
LogPrint ("Requested ", key, " not found. ", numExcluded, " excluded"); |
|
|
|
std::vector<IdentHash> routers; |
|
|
|
std::set<IdentHash> excludedRouters; |
|
|
|
if (numExcluded > 0) |
|
|
|
for (int i = 0; i < numExcluded; i++) |
|
|
|
{ |
|
|
|
{ |
|
|
|
std::set<IdentHash> excludedRouters; |
|
|
|
excludedRouters.insert (excluded); |
|
|
|
for (int i = 0; i < numExcluded; i++) |
|
|
|
excluded += 32; |
|
|
|
{ |
|
|
|
} |
|
|
|
excludedRouters.insert (excluded); |
|
|
|
replyMsg = CreateDatabaseSearchReply (ident, GetClosestFloodfills (ident, 3, excludedRouters)); |
|
|
|
excluded += 32; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
for (int i = 0; i < 3; i++) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto floodfill = GetClosestFloodfill (ident, excludedRouters); |
|
|
|
|
|
|
|
if (floodfill) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
routers.push_back (floodfill->GetIdentHash ()); |
|
|
|
|
|
|
|
excludedRouters.insert (floodfill->GetIdentHash ()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
routers = GetClosestFloodfills (ident, 3); |
|
|
|
|
|
|
|
replyMsg = CreateDatabaseSearchReply (ident, routers); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -955,7 +940,8 @@ namespace data |
|
|
|
return r; |
|
|
|
return r; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
std::vector<IdentHash> NetDb::GetClosestFloodfills (const IdentHash& destination, size_t num) const |
|
|
|
std::vector<IdentHash> NetDb::GetClosestFloodfills (const IdentHash& destination, size_t num, |
|
|
|
|
|
|
|
std::set<IdentHash>& excluded) const |
|
|
|
{ |
|
|
|
{ |
|
|
|
struct Sorted |
|
|
|
struct Sorted |
|
|
|
{ |
|
|
|
{ |
|
|
@ -990,8 +976,12 @@ namespace data |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (i < num) |
|
|
|
if (i < num) |
|
|
|
{ |
|
|
|
{ |
|
|
|
res.push_back (it.r->GetIdentHash ()); |
|
|
|
auto& ident = it.r->GetIdentHash (); |
|
|
|
i++; |
|
|
|
if (!excluded.count (ident)) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
res.push_back (ident); |
|
|
|
|
|
|
|
i++; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
else |
|
|
|
break; |
|
|
|
break; |
|
|
|