mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	clean up node info immediately if it reaches the timeout or if it needs refreshing but won't be pinged due to being unimportant
This commit is contained in:
		
							parent
							
								
									f59852b1e1
								
							
						
					
					
						commit
						59093aa43b
					
				
					 1 changed files with 9 additions and 1 deletions
				
			
		| 
						 | 
					@ -325,7 +325,15 @@ func (t *dht) doMaintenance() {
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	t.callbacks = newCallbacks
 | 
						t.callbacks = newCallbacks
 | 
				
			||||||
	for infoID, info := range t.table {
 | 
						for infoID, info := range t.table {
 | 
				
			||||||
		if now.Sub(info.recv) > dht_timeout || info.pings > 6 {
 | 
							switch {
 | 
				
			||||||
 | 
							case info.pings > 6:
 | 
				
			||||||
 | 
								// It failed to respond to too many pings
 | 
				
			||||||
 | 
								fallthrough
 | 
				
			||||||
 | 
							case now.Sub(info.recv) > dht_timeout:
 | 
				
			||||||
 | 
								// It's too old
 | 
				
			||||||
 | 
								fallthrough
 | 
				
			||||||
 | 
							case info.dirty && now.Sub(info.recv) > dht_max_delay_dirty && !t.isImportant(info):
 | 
				
			||||||
 | 
								// We won't ping it to refresh it, so just drop it
 | 
				
			||||||
			delete(t.table, infoID)
 | 
								delete(t.table, infoID)
 | 
				
			||||||
			t.imp = nil
 | 
								t.imp = nil
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue