mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 11:15:07 +03:00 
			
		
		
		
	don't update recv time for known nodes that ping us or known peers
This commit is contained in:
		
							parent
							
								
									c0531627bc
								
							
						
					
					
						commit
						671c7f2a47
					
				
					 2 changed files with 6 additions and 2 deletions
				
			
		| 
						 | 
					@ -180,7 +180,7 @@ func (t *dht) handleReq(req *dhtReq) {
 | 
				
			||||||
		coords: req.Coords,
 | 
							coords: req.Coords,
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	imp := t.getImportant()
 | 
						imp := t.getImportant()
 | 
				
			||||||
	if t.isImportant(&info, imp) {
 | 
						if _, isIn := t.table[*info.getNodeID()]; !isIn || t.isImportant(&info, imp) {
 | 
				
			||||||
		t.insert(&info)
 | 
							t.insert(&info)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -91,8 +91,12 @@ func (r *router) mainLoop() {
 | 
				
			||||||
		case p := <-r.send:
 | 
							case p := <-r.send:
 | 
				
			||||||
			r.sendPacket(p)
 | 
								r.sendPacket(p)
 | 
				
			||||||
		case info := <-r.core.dht.peers:
 | 
							case info := <-r.core.dht.peers:
 | 
				
			||||||
 | 
								now := time.Now()
 | 
				
			||||||
 | 
								oldInfo, isIn := r.core.dht.table[*info.getNodeID()]
 | 
				
			||||||
			r.core.dht.insert(info)
 | 
								r.core.dht.insert(info)
 | 
				
			||||||
			info.throttle = 0
 | 
								if isIn && now.Sub(oldInfo.recv) < 45*time.Second {
 | 
				
			||||||
 | 
									info.recv = oldInfo.recv
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		case <-r.reset:
 | 
							case <-r.reset:
 | 
				
			||||||
			r.core.sessions.resetInits()
 | 
								r.core.sessions.resetInits()
 | 
				
			||||||
			r.core.dht.reset()
 | 
								r.core.dht.reset()
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue