mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	Merge pull request #64 from Arceliar/dht
Limit DHT pings to 1/min per node
This commit is contained in:
		
						commit
						48ced483d6
					
				
					 1 changed files with 5 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -451,7 +451,7 @@ func (t *dht) doMaintenance() {
 | 
			
		|||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		if oldest != nil {
 | 
			
		||||
		if oldest != nil && time.Since(oldest.recv) > time.Minute {
 | 
			
		||||
			t.addToMill(oldest, nil)
 | 
			
		||||
		} // if the DHT isn't empty
 | 
			
		||||
		// Refresh buckets
 | 
			
		||||
| 
						 | 
				
			
			@ -460,8 +460,10 @@ func (t *dht) doMaintenance() {
 | 
			
		|||
		}
 | 
			
		||||
		target := t.getTarget(t.offset)
 | 
			
		||||
		for _, info := range t.lookup(target) {
 | 
			
		||||
			t.addToMill(info, target)
 | 
			
		||||
			break
 | 
			
		||||
			if time.Since(info.recv) > time.Minute {
 | 
			
		||||
				t.addToMill(info, target)
 | 
			
		||||
				break
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		t.offset++
 | 
			
		||||
	}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue