From c937cb2f0732b94265f9c97d43d09a165bfd66c6 Mon Sep 17 00:00:00 2001
From: jrandom <jrandom>
Date: Tue, 27 Jul 2004 06:34:30 +0000
Subject: [PATCH] no need to test a peer that we already know is up

---
 .../i2p/router/message/BuildTestMessageJob.java    | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/router/java/src/net/i2p/router/message/BuildTestMessageJob.java b/router/java/src/net/i2p/router/message/BuildTestMessageJob.java
index dc7d911375..6b0163865a 100644
--- a/router/java/src/net/i2p/router/message/BuildTestMessageJob.java
+++ b/router/java/src/net/i2p/router/message/BuildTestMessageJob.java
@@ -26,6 +26,7 @@ import net.i2p.router.MessageSelector;
 import net.i2p.router.ReplyJob;
 import net.i2p.router.Router;
 import net.i2p.router.RouterContext;
+import net.i2p.router.peermanager.PeerProfile;
 import net.i2p.util.Log;
 
 /**
@@ -69,6 +70,11 @@ public class BuildTestMessageJob extends JobImpl {
     public String getName() { return "Build Test Message"; }
     
     public void runJob() {
+        if (alreadyKnownReachable()) {
+            getContext().jobQueue().addJob(_onSend);
+            return;
+        }
+        
         // This is a test message - build a garlic with a DeliveryStatusMessage that
         // first goes to the peer then back to us.
         if (_log.shouldLog(Log.DEBUG))
@@ -81,6 +87,14 @@ public class BuildTestMessageJob extends JobImpl {
         getContext().jobQueue().addJob(job);
     }
     
+    private boolean alreadyKnownReachable() {
+        PeerProfile profile = getContext().profileOrganizer().getProfile(_target.getIdentity().getHash());
+        if ( (profile == null) || (!profile.getIsActive()) )
+            return false;
+        else
+            return true;
+    }
+    
     private MessageSelector buildMessageSelector() {
         return new TestMessageSelector(_testMessageKey, _timeoutMs + getContext().clock().now());
     }
-- 
GitLab