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

Method GetHighBandwidthRandomRouter

libi2pd/NetDb.cpp:1191–1210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1189 }
1190
1191 std::shared_ptr<const RouterInfo> NetDb::GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith,
1192 bool reverse, bool endpoint) const
1193 {
1194 bool checkIsReal = i2p::tunnel::tunnels.GetPreciseTunnelCreationSuccessRate () < NETDB_TUNNEL_CREATION_RATE_THRESHOLD && // too low rate
1195 context.GetUptime () > NETDB_CHECK_FOR_EXPIRATION_UPTIME; // after 10 minutes uptime
1196 return GetRandomRouter (
1197 [compatibleWith, reverse, endpoint, checkIsReal](std::shared_ptr<const RouterInfo> router)->bool
1198 {
1199 return !router->IsHidden () && router != compatibleWith &&
1200 (reverse ? (compatibleWith->IsReachableFrom (*router) && router->GetCompatibleTransports (true)) :
1201 router->IsReachableFrom (*compatibleWith)) && !router->IsNAT2NATOnly (*compatibleWith) &&
1202 (router->GetCaps () & RouterInfo::eHighBandwidth) &&
1203 router->GetVersion () >= NETDB_MIN_HIGHBANDWIDTH_VERSION &&
1204 router->IsECIES () && !router->IsHighCongestion (true) &&
1205 (!i2p::transport::transports.IsCheckReserved () || (!router->IsSameFamily (*compatibleWith) && !router->IsSameSubnet (*compatibleWith))) &&
1206 (!checkIsReal || router->GetProfile ()->IsReal ()) &&
1207 (!endpoint || (router->IsV4 () && (!reverse || router->IsPublished (true)))); // endpoint must be ipv4 and published if inbound(reverse)
1208
1209 });
1210 }
1211
1212 template<typename Filter>
1213 std::shared_ptr<const RouterInfo> NetDb::GetRandomRouter (Filter filter) const

Callers 1

SelectNextHopMethod · 0.80

Calls 15

GetUptimeMethod · 0.80
IsReachableFromMethod · 0.80
IsNAT2NATOnlyMethod · 0.80
GetCapsMethod · 0.80
IsECIESMethod · 0.80
IsHighCongestionMethod · 0.80
IsCheckReservedMethod · 0.80
IsSameFamilyMethod · 0.80
IsRealMethod · 0.80
GetProfileMethod · 0.80

Tested by

no test coverage detected