mirror of
				https://github.com/yggdrasil-network/yggdrasil-go.git
				synced 2025-11-04 03:05:07 +03:00 
			
		
		
		
	more work on backpressure, but still needs more testing
This commit is contained in:
		
							parent
							
								
									4b83efa218
								
							
						
					
					
						commit
						0ad801bcfe
					
				
					 1 changed files with 20 additions and 6 deletions
				
			
		| 
						 | 
					@ -588,17 +588,31 @@ func (t *switchTable) handleIn(packet []byte, idle map[switchPort]struct{}) bool
 | 
				
			||||||
		ports[0].sendPacket(packet)
 | 
							ports[0].sendPacket(packet)
 | 
				
			||||||
		return true
 | 
							return true
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						table := t.getTable()
 | 
				
			||||||
 | 
						myDist := table.self.dist(coords)
 | 
				
			||||||
 | 
						var best *peer
 | 
				
			||||||
 | 
						bestDist := myDist
 | 
				
			||||||
	for port := range idle {
 | 
						for port := range idle {
 | 
				
			||||||
		if to := ports[port]; to != nil {
 | 
							if to := ports[port]; to != nil {
 | 
				
			||||||
			if t.portIsCloser(coords, port) {
 | 
								if info, isIn := table.elems[to.port]; isIn {
 | 
				
			||||||
				delete(idle, port)
 | 
									dist := info.locator.dist(coords)
 | 
				
			||||||
				to.sendPacket(packet)
 | 
									if !(dist < bestDist) {
 | 
				
			||||||
				return true
 | 
										continue
 | 
				
			||||||
 | 
									}
 | 
				
			||||||
 | 
									best = to
 | 
				
			||||||
 | 
									bestDist = dist
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	// Didn't find anyone idle to send it to
 | 
						if best != nil {
 | 
				
			||||||
	return false
 | 
							// Send to the best idle next hop
 | 
				
			||||||
 | 
							delete(idle, best.port)
 | 
				
			||||||
 | 
							best.sendPacket(packet)
 | 
				
			||||||
 | 
							return true
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							// Didn't find anyone idle to send it to
 | 
				
			||||||
 | 
							return false
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Handles incoming idle notifications
 | 
					// Handles incoming idle notifications
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue