mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
make more attempts to select not bad hop
This commit is contained in:
parent
cb8fbb0135
commit
b092e712ec
3 changed files with 19 additions and 6 deletions
|
@ -494,11 +494,23 @@ namespace tunnel
|
|||
std::shared_ptr<const i2p::data::RouterInfo> TunnelPool::SelectNextHop (std::shared_ptr<const i2p::data::RouterInfo> prevHop,
|
||||
bool reverse, bool endpoint) const
|
||||
{
|
||||
auto hop = IsExploratory () ? i2p::data::netdb.GetRandomRouter (prevHop, reverse, endpoint):
|
||||
i2p::data::netdb.GetHighBandwidthRandomRouter (prevHop, reverse, endpoint);
|
||||
|
||||
if (!hop || hop->GetProfile ()->IsBad ())
|
||||
hop = i2p::data::netdb.GetRandomRouter (prevHop, reverse, endpoint);
|
||||
bool tryHighBandwidth = !IsExploratory ();
|
||||
std::shared_ptr<const i2p::data::RouterInfo> hop;
|
||||
for (int i = 0; i < TUNNEL_POOL_MAX_HOP_SELECTION_ATTEMPTS; i++)
|
||||
{
|
||||
hop = tryHighBandwidth ?
|
||||
i2p::data::netdb.GetHighBandwidthRandomRouter (prevHop, reverse, endpoint) :
|
||||
i2p::data::netdb.GetRandomRouter (prevHop, reverse, endpoint);
|
||||
if (hop)
|
||||
{
|
||||
if (!hop->GetProfile ()->IsBad ())
|
||||
break;
|
||||
}
|
||||
else if (tryHighBandwidth)
|
||||
tryHighBandwidth = false;
|
||||
else
|
||||
return nullptr;
|
||||
}
|
||||
return hop;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue