Merge pull request #64 from Arceliar/dht

Limit DHT pings to 1/min per node
This commit is contained in:
Neil Alexander 2018-03-17 20:46:47 +00:00 committed by GitHub
commit 48ced483d6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -451,7 +451,7 @@ func (t *dht) doMaintenance() {
} }
} }
} }
if oldest != nil { if oldest != nil && time.Since(oldest.recv) > time.Minute {
t.addToMill(oldest, nil) t.addToMill(oldest, nil)
} // if the DHT isn't empty } // if the DHT isn't empty
// Refresh buckets // Refresh buckets
@ -460,8 +460,10 @@ func (t *dht) doMaintenance() {
} }
target := t.getTarget(t.offset) target := t.getTarget(t.offset)
for _, info := range t.lookup(target) { for _, info := range t.lookup(target) {
t.addToMill(info, target) if time.Since(info.recv) > time.Minute {
break t.addToMill(info, target)
break
}
} }
t.offset++ t.offset++
} }