From 1ce63add683230d292c5284e2c710a5fd10401b0 Mon Sep 17 00:00:00 2001
From: Beaudan <beau@loki.network>
Date: Thu, 31 Jan 2019 16:33:33 +1100
Subject: [PATCH] Simplified the addContactP2pDetails logic cause it was silly

---
 js/modules/loki_p2p_api.js | 36 +++++++++---------------------------
 1 file changed, 9 insertions(+), 27 deletions(-)

diff --git a/js/modules/loki_p2p_api.js b/js/modules/loki_p2p_api.js
index 77da5c696..598a7d0a4 100644
--- a/js/modules/loki_p2p_api.js
+++ b/js/modules/loki_p2p_api.js
@@ -16,34 +16,16 @@ class LokiP2pAPI extends EventEmitter {
         ? 60 * 1000 // 1 minute
         : 2 * 60 * 1000; // 2 minutes
 
-    if (!this.contactP2pDetails[pubKey]) {
-      // If this is the first time we are getting this contacts details
-      // then we try to ping them straight away
-      this.contactP2pDetails[pubKey] = {
-        address,
-        port,
-        timerDuration,
-        isOnline: false,
-        pingTimer: null,
-      };
-      this.pingContact(pubKey);
-      return;
+    if (this.contactP2pDetails[pubKey] && this.contactP2pDetails[pubKey].pingTimer) {
+      clearTimeout(this.contactP2pDetails[pubKey].pingTimer);
     }
-
-    clearTimeout(this.contactP2pDetails[pubKey].pingTimer);
-    if (
-      this.contactP2pDetails[pubKey].address !== address ||
-      this.contactP2pDetails[pubKey].port !== port
-    ) {
-      // If this contact has changed their details
-      // then we try to ping them straight away
-      this.contactP2pDetails[pubKey].address = address;
-      this.contactP2pDetails[pubKey].port = port;
-      this.contactP2pDetails[pubKey].isOnline = false;
-      this.pingContact(pubKey);
-      return;
-    }
-
+    this.contactP2pDetails[pubKey] = {
+      address,
+      port,
+      timerDuration,
+      isOnline: false,
+      pingTimer: null,
+    };
     if (resetTimer) {
       // If this contact is simply sharing the same details with us
       // then we just reset our timer