mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	check root before adding peers to the switch lookupTable, instead of during each lookup
This commit is contained in:
		
							parent
							
								
									430d49d8a4
								
							
						
					
					
						commit
						0fc7401635
					
				
					 1 changed files with 3 additions and 3 deletions
				
			
		| 
						 | 
					@ -390,6 +390,9 @@ func (t *switchTable) updateTable() {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	for _, pinfo := range t.data.peers {
 | 
						for _, pinfo := range t.data.peers {
 | 
				
			||||||
		//if !pinfo.forward { continue }
 | 
							//if !pinfo.forward { continue }
 | 
				
			||||||
 | 
							if pinfo.locator.root != newTable.self.root {
 | 
				
			||||||
 | 
								continue
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
		loc := pinfo.locator.clone()
 | 
							loc := pinfo.locator.clone()
 | 
				
			||||||
		loc.coords = loc.coords[:len(loc.coords)-1] // Remove the them->self link
 | 
							loc.coords = loc.coords[:len(loc.coords)-1] // Remove the them->self link
 | 
				
			||||||
		newTable.elems = append(newTable.elems, tableElem{
 | 
							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
 | 
						// score is in units of bandwidth / distance
 | 
				
			||||||
	bestScore := float64(-1)
 | 
						bestScore := float64(-1)
 | 
				
			||||||
	for _, info := range table.elems {
 | 
						for _, info := range table.elems {
 | 
				
			||||||
		if info.locator.root != table.self.root {
 | 
					 | 
				
			||||||
			continue
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
		dist := info.locator.dist(dest) //getDist(info.locator.coords)
 | 
							dist := info.locator.dist(dest) //getDist(info.locator.coords)
 | 
				
			||||||
		if !(dist < myDist) {
 | 
							if !(dist < myDist) {
 | 
				
			||||||
			continue
 | 
								continue
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue