mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-23 18:15:24 +00:00
check root before adding peers to the switch lookupTable, instead of during each lookup
This commit is contained in:
parent
430d49d8a4
commit
0fc7401635
@ -390,6 +390,9 @@ func (t *switchTable) updateTable() {
|
||||
}
|
||||
for _, pinfo := range t.data.peers {
|
||||
//if !pinfo.forward { continue }
|
||||
if pinfo.locator.root != newTable.self.root {
|
||||
continue
|
||||
}
|
||||
loc := pinfo.locator.clone()
|
||||
loc.coords = loc.coords[:len(loc.coords)-1] // Remove the them->self link
|
||||
newTable.elems = append(newTable.elems, tableElem{
|
||||
@ -422,9 +425,6 @@ func (t *switchTable) lookup(dest []byte, ttl uint64) (switchPort, uint64) {
|
||||
// score is in units of bandwidth / distance
|
||||
bestScore := float64(-1)
|
||||
for _, info := range table.elems {
|
||||
if info.locator.root != table.self.root {
|
||||
continue
|
||||
}
|
||||
dist := info.locator.dist(dest) //getDist(info.locator.coords)
|
||||
if !(dist < myDist) {
|
||||
continue
|
||||
|
Loading…
Reference in New Issue
Block a user