mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
kademlia
This commit is contained in:
parent
4f9a977022
commit
4f1f08b805
6 changed files with 78 additions and 0 deletions
21
NetDb.cpp
21
NetDb.cpp
|
@ -388,5 +388,26 @@ namespace data
|
|||
{
|
||||
if (msg) m_Queue.Put (msg);
|
||||
}
|
||||
|
||||
const RouterInfo * NetDb::GetClosestFloodfill (const IdentHash& destination) const
|
||||
{
|
||||
RouterInfo * r = nullptr;
|
||||
XORMetric minMetric;
|
||||
RoutingKey destKey = CreateRoutingKey (destination);
|
||||
minMetric.SetMax ();
|
||||
for (auto it: m_RouterInfos)
|
||||
{
|
||||
if (it.second->IsFloodfill () &&! it.second->IsUnreachable ())
|
||||
{
|
||||
XORMetric m = destKey ^ it.second->GetRoutingKey ();
|
||||
if (m < minMetric)
|
||||
{
|
||||
minMetric = m;
|
||||
r = it.second;
|
||||
}
|
||||
}
|
||||
}
|
||||
return r;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue