From 671c7f2a479facd407d69f03b888ba55e83a007d Mon Sep 17 00:00:00 2001 From: Arceliar Date: Sun, 28 Oct 2018 15:04:44 -0500 Subject: [PATCH] don't update recv time for known nodes that ping us or known peers --- src/yggdrasil/dht.go | 2 +- src/yggdrasil/router.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/yggdrasil/dht.go b/src/yggdrasil/dht.go index 3774b5c..a94de5e 100644 --- a/src/yggdrasil/dht.go +++ b/src/yggdrasil/dht.go @@ -180,7 +180,7 @@ func (t *dht) handleReq(req *dhtReq) { coords: req.Coords, } imp := t.getImportant() - if t.isImportant(&info, imp) { + if _, isIn := t.table[*info.getNodeID()]; !isIn || t.isImportant(&info, imp) { t.insert(&info) } } diff --git a/src/yggdrasil/router.go b/src/yggdrasil/router.go index 27aad8d..cd01e74 100644 --- a/src/yggdrasil/router.go +++ b/src/yggdrasil/router.go @@ -91,8 +91,12 @@ func (r *router) mainLoop() { case p := <-r.send: r.sendPacket(p) case info := <-r.core.dht.peers: + now := time.Now() + oldInfo, isIn := r.core.dht.table[*info.getNodeID()] r.core.dht.insert(info) - info.throttle = 0 + if isIn && now.Sub(oldInfo.recv) < 45*time.Second { + info.recv = oldInfo.recv + } case <-r.reset: r.core.sessions.resetInits() r.core.dht.reset()