I2P Address: [http://git.idk.i2p]

Skip to content
Snippets Groups Projects
Commit 435683c5 authored by zzz's avatar zzz
Browse files

* Tunnels: Use exploratory tunnels to help maintain a minimum number

             of connected peers
parent 1f3f17c8
No related branches found
No related tags found
No related merge requests found
...@@ -68,15 +68,40 @@ class ExploratoryPeerSelector extends TunnelPeerSelector { ...@@ -68,15 +68,40 @@ class ExploratoryPeerSelector extends TunnelPeerSelector {
} }
private static final int MIN_NONFAILING_PCT = 25; private static final int MIN_NONFAILING_PCT = 25;
private static final int MIN_ACTIVE_PEERS_STARTUP = 6;
private static final int MIN_ACTIVE_PEERS = 12;
/**
* Should we pick from the high cap pool instead of the larger not failing pool?
* This should return false most of the time, but if the not-failing pool's
* build success rate is much worse, return true so that reliability
* is maintained.
*/
private static boolean shouldPickHighCap(RouterContext ctx) { private static boolean shouldPickHighCap(RouterContext ctx) {
if (Boolean.valueOf(ctx.getProperty("router.exploreHighCapacity", "false")).booleanValue()) if (ctx.getBooleanProperty("router.exploreHighCapacity"))
return true; return true;
// no need to explore too wildly at first
// If we don't have enough connected peers, use exploratory
// tunnel building to get us better-connected.
// This is a tradeoff, we could easily lose our exploratory tunnels,
// but with so few connected peers, anonymity suffers and reliability
// will decline also, as we repeatedly try to build tunnels
// through the same few peers.
int active = ctx.commSystem().countActivePeers();
if (active < MIN_ACTIVE_PEERS_STARTUP)
return false;
// no need to explore too wildly at first (if we have enough connected peers)
if (ctx.router().getUptime() <= 5*60*1000) if (ctx.router().getUptime() <= 5*60*1000)
return true; return true;
// or at the end // or at the end
if (ctx.router().gracefulShutdownInProgress()) if (ctx.router().gracefulShutdownInProgress())
return true; return true;
// see above
if (active < MIN_ACTIVE_PEERS)
return false;
// ok, if we aren't explicitly asking for it, we should try to pick peers // ok, if we aren't explicitly asking for it, we should try to pick peers
// randomly from the 'not failing' pool. However, if we are having a // randomly from the 'not failing' pool. However, if we are having a
// hard time building exploratory tunnels, lets fall back again on the // hard time building exploratory tunnels, lets fall back again on the
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment