mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03: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:
		
							parent
							
								
									9fac5355eb
								
							
						
					
					
						commit
						201dbec63d
					
				
					 1 changed files with 4 additions and 0 deletions
				
			
		| 
						 | 
					@ -387,6 +387,8 @@ func (t *dht) getImportant() []*dhtInfo {
 | 
				
			||||||
			if dist < minDist {
 | 
								if dist < minDist {
 | 
				
			||||||
				minDist = dist
 | 
									minDist = dist
 | 
				
			||||||
				important = append(important, info)
 | 
									important = append(important, info)
 | 
				
			||||||
 | 
								} else if len(important) < 2 {
 | 
				
			||||||
 | 
									important = append(important, info)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		var temp []*dhtInfo
 | 
							var temp []*dhtInfo
 | 
				
			||||||
| 
						 | 
					@ -397,6 +399,8 @@ func (t *dht) getImportant() []*dhtInfo {
 | 
				
			||||||
			if dist < minDist {
 | 
								if dist < minDist {
 | 
				
			||||||
				minDist = dist
 | 
									minDist = dist
 | 
				
			||||||
				temp = append(temp, info)
 | 
									temp = append(temp, info)
 | 
				
			||||||
 | 
								} else if len(temp) < 2 {
 | 
				
			||||||
 | 
									temp = append(temp, info)
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		for idx := len(temp) - 1; idx >= 0; idx-- {
 | 
							for idx := len(temp) - 1; idx >= 0; idx-- {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue