From 0773e584fd09fef858ccbf0d93521ac22d367e02 Mon Sep 17 00:00:00 2001
From: Juan Batiz-Benet <juan@benet.ai>
Date: Tue, 16 Sep 2014 06:40:17 -0700
Subject: [PATCH] updated Update function

---
 routing/dht/dht.go | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/routing/dht/dht.go b/routing/dht/dht.go
index 596ba3dd..f2de949c 100644
--- a/routing/dht/dht.go
+++ b/routing/dht/dht.go
@@ -302,24 +302,25 @@ func (dht *IpfsDHT) putLocal(key u.Key, value []byte) error {
 	return dht.datastore.Put(ds.NewKey(string(key)), value)
 }
 
-// Update TODO(chas) Document this function
+// Update signals to all routingTables to Update their last-seen status
+// on the given peer.
 func (dht *IpfsDHT) Update(p *peer.Peer) {
+	removedCount := 0
 	for _, route := range dht.routingTables {
 		removed := route.Update(p)
 		// Only close the connection if no tables refer to this peer
 		if removed != nil {
-			found := false
-			for _, r := range dht.routingTables {
-				if r.Find(removed.ID) != nil {
-					found = true
-					break
-				}
-			}
-			if !found {
-				dht.network.CloseConnection(removed)
-			}
+			removedCount++
 		}
 	}
+
+	// Only close the connection if no tables refer to this peer
+	// if removedCount == len(dht.routingTables) {
+	// 	dht.network.ClosePeer(p)
+	// }
+	// ACTUALLY, no, let's not just close the connection. it may be connected
+	// due to other things. it seems that we just need connection timeouts
+	// after some deadline of inactivity.
 }
 
 // Find looks for a peer with a given ID connected to this dht and returns the peer and the table it was found in.
-- 
GitLab