From 59093aa43b69fa33c93efe65347e24fc4a027d4f Mon Sep 17 00:00:00 2001 From: Arceliar Date: Fri, 21 Dec 2018 17:45:24 -0600 Subject: [PATCH] clean up node info immediately if it reaches the timeout or if it needs refreshing but won't be pinged due to being unimportant --- src/yggdrasil/dht.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/yggdrasil/dht.go b/src/yggdrasil/dht.go index e360cecb..96883940 100644 --- a/src/yggdrasil/dht.go +++ b/src/yggdrasil/dht.go @@ -325,7 +325,15 @@ func (t *dht) doMaintenance() { } t.callbacks = newCallbacks for infoID, info := range t.table { - if now.Sub(info.recv) > dht_timeout || info.pings > 6 { + switch { + case info.pings > 6: + // It failed to respond to too many pings + fallthrough + case now.Sub(info.recv) > dht_timeout: + // It's too old + fallthrough + case info.dirty && now.Sub(info.recv) > dht_max_delay_dirty && !t.isImportant(info): + // We won't ping it to refresh it, so just drop it delete(t.table, infoID) t.imp = nil }