MCPcopy Create free account
hub / github.com/PurpleI2P/i2pd / SelectNextHop

Method SelectNextHop

libi2pd/TunnelPool.cpp:570–594  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

568 }
569
570 std::shared_ptr<const i2p::data::RouterInfo> TunnelPool::SelectNextHop (std::shared_ptr<const i2p::data::RouterInfo> prevHop,
571 bool reverse, bool endpoint) const
572 {
573 bool tryClient = !IsExploratory () && !i2p::context.IsLimitedConnectivity ();
574 std::shared_ptr<const i2p::data::RouterInfo> hop;
575 for (int i = 0; i < TUNNEL_POOL_MAX_HOP_SELECTION_ATTEMPTS; i++)
576 {
577 hop = tryClient ?
578 (m_IsHighBandwidth ?
579 i2p::data::netdb.GetHighBandwidthRandomRouter (prevHop, reverse, endpoint) :
580 i2p::data::netdb.GetRandomRouter (prevHop, reverse, endpoint, true)):
581 i2p::data::netdb.GetRandomRouter (prevHop, reverse, endpoint, false);
582 if (hop)
583 {
584 if ((!hop->HasProfile () || !hop->GetProfile ()->IsBad ()) &&
585 (prevHop != i2p::context.GetSharedRouterInfo () || !i2p::transport::transports.IsTooManyConnectionsFromSubnet (hop)))
586 break;
587 }
588 else if (tryClient)
589 tryClient = false;
590 else
591 return nullptr;
592 }
593 return hop;
594 }
595
596 bool TunnelPool::StandardSelectPeers(Path & path, int numHops, bool inbound, SelectHopFunc nextHop)
597 {

Callers

nothing calls this directly

Calls 8

IsLimitedConnectivityMethod · 0.80
GetRandomRouterMethod · 0.80
HasProfileMethod · 0.80
IsBadMethod · 0.80
GetProfileMethod · 0.80
GetSharedRouterInfoMethod · 0.80

Tested by

no test coverage detected