]> Sergey Matveev's repositories - btrtrc.git/commitdiff
dht: Fix "good" node determination
authorMatt Joiner <anacrolix@gmail.com>
Tue, 18 Nov 2014 00:02:16 +0000 (18:02 -0600)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 18 Nov 2014 00:02:16 +0000 (18:02 -0600)
dht/dht.go

index b8acae4b8fe857d132e31f19806c0d9e2c67c530..c6d84142d51e3eb83ad6ea279c82dc6a5e409573 100644 (file)
@@ -119,7 +119,13 @@ func (n *Node) Good() bool {
        if len(n.id) != 20 {
                return false
        }
-       if time.Now().Sub(n.lastHeardFrom) >= 15*time.Minute {
+       if n.lastSentTo.IsZero() {
+               return true
+       }
+       if n.lastSentTo.Before(n.lastHeardFrom) {
+               return true
+       }
+       if time.Now().Sub(n.lastHeardFrom) >= 1*time.Minute {
                return false
        }
        return true