mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
select high bandwidth routers for client tunnels
This commit is contained in:
parent
c4ec2ea297
commit
79d2f69837
4 changed files with 42 additions and 17 deletions
36
NetDb.cpp
36
NetDb.cpp
|
@ -785,22 +785,34 @@ namespace data
|
|||
}
|
||||
}
|
||||
|
||||
const RouterInfo * NetDb::GetRandomRouter () const
|
||||
{
|
||||
return GetRandomRouter (
|
||||
[](const RouterInfo * router)->bool
|
||||
{
|
||||
return !router->IsHidden ();
|
||||
});
|
||||
}
|
||||
|
||||
const RouterInfo * NetDb::GetRandomRouter (const RouterInfo * compatibleWith) const
|
||||
{
|
||||
if (compatibleWith)
|
||||
return GetRandomRouter (
|
||||
[compatibleWith](const RouterInfo * router)->bool
|
||||
{
|
||||
return !router->IsHidden () && router->IsCompatible (*compatibleWith);
|
||||
});
|
||||
else
|
||||
return GetRandomRouter (
|
||||
[](const RouterInfo * router)->bool
|
||||
{
|
||||
return !router->IsHidden ();
|
||||
});
|
||||
return GetRandomRouter (
|
||||
[compatibleWith](const RouterInfo * router)->bool
|
||||
{
|
||||
return !router->IsHidden () && router->IsCompatible (*compatibleWith);
|
||||
});
|
||||
}
|
||||
|
||||
const RouterInfo * NetDb::GetHighBandwidthRandomRouter (const RouterInfo * compatibleWith) const
|
||||
{
|
||||
return GetRandomRouter (
|
||||
[compatibleWith](const RouterInfo * router)->bool
|
||||
{
|
||||
return !router->IsHidden () && router->IsCompatible (*compatibleWith) &&
|
||||
(router->GetCaps () & RouterInfo::eHighBandwidth);
|
||||
});
|
||||
}
|
||||
|
||||
template<typename Filter>
|
||||
const RouterInfo * NetDb::GetRandomRouter (Filter filter) const
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue