From 0a938d9048d5c7c9e8c53925ccb3be07ad2f8d54 Mon Sep 17 00:00:00 2001
From: zzz <zzz@mail.i2p>
Date: Wed, 7 Jan 2015 20:11:04 +0000
Subject: [PATCH] Router: Don't reset uptime after a soft restart Tunnels:
 Temporarily increase exploratory tunnel quantity at startup, so that netdb
 refresh will work better

---
 router/java/src/net/i2p/router/Router.java                 | 3 ++-
 router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java | 5 +++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/router/java/src/net/i2p/router/Router.java b/router/java/src/net/i2p/router/Router.java
index b390cbcc06..2b37900171 100644
--- a/router/java/src/net/i2p/router/Router.java
+++ b/router/java/src/net/i2p/router/Router.java
@@ -1273,7 +1273,8 @@ public class Router implements RouterClock.ClockShiftListener {
             changeState(State.RESTARTING);
         }
         ((RouterClock) _context.clock()).removeShiftListener(this);
-        _started = _context.clock().now();
+        // Let's not stop accepting tunnels, etc
+        //_started = _context.clock().now();
         Thread t = new Thread(new Restarter(_context), "Router Restart");
         t.setPriority(Thread.NORM_PRIORITY + 1);
         t.start();
diff --git a/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java b/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java
index 3024063e1a..cc42da3ab6 100644
--- a/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java
+++ b/router/java/src/net/i2p/router/tunnel/pool/TunnelPool.java
@@ -52,6 +52,7 @@ public class TunnelPool {
     /** if less than one success in this many, reduce length (exploratory only) */
     private static final int BUILD_TRIES_LENGTH_OVERRIDE_1 = 10;
     private static final int BUILD_TRIES_LENGTH_OVERRIDE_2 = 18;
+    private static final long STARTUP_TIME = 30*60*1000;
     
     TunnelPool(RouterContext ctx, TunnelPoolManager mgr, TunnelPoolSettings settings, TunnelPeerSelector sel) {
         _context = ctx;
@@ -348,6 +349,10 @@ public class TunnelPool {
                 }
             }
         }
+        if (_settings.isExploratory() && _context.router().getUptime() < STARTUP_TIME) {
+            // more exploratory during startup, when we are refreshing the netdb RIs
+            rv++;
+        }
         return rv;
     }
 
-- 
GitLab