5
0
mirror of https://github.com/cwinfo/yggdrasil-go.git synced 2024-11-26 00:11:36 +00:00

always keep the 2 closest nodes in each direction around the dht ring, possibly helps things recover faster after joins/leaves

This commit is contained in:
Arceliar 2019-12-25 19:01:20 -06:00
parent 9fac5355eb
commit 201dbec63d

View File

@ -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-- {