From 201dbec63d2bc629bb26ed7515112d223f5147cb Mon Sep 17 00:00:00 2001 From: Arceliar Date: Wed, 25 Dec 2019 19:01:20 -0600 Subject: [PATCH] always keep the 2 closest nodes in each direction around the dht ring, possibly helps things recover faster after joins/leaves --- src/yggdrasil/dht.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/yggdrasil/dht.go b/src/yggdrasil/dht.go index 7216594..013fd1e 100644 --- a/src/yggdrasil/dht.go +++ b/src/yggdrasil/dht.go @@ -387,6 +387,8 @@ func (t *dht) getImportant() []*dhtInfo { if dist < minDist { minDist = dist important = append(important, info) + } else if len(important) < 2 { + important = append(important, info) } } var temp []*dhtInfo @@ -397,6 +399,8 @@ func (t *dht) getImportant() []*dhtInfo { if dist < minDist { minDist = dist temp = append(temp, info) + } else if len(temp) < 2 { + temp = append(temp, info) } } for idx := len(temp) - 1; idx >= 0; idx-- {