mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 22:25:07 +03:00
Switch connAddr (udp map key) from string to a struct that allocates less. Reduce some other allocations. Use larger channel buffers to reduce backpressure from runtime jitter.
This commit is contained in:
parent
ef1e0c902f
commit
75965b6da4
6 changed files with 60 additions and 28 deletions
|
@ -171,10 +171,10 @@ func (p *peer) handleTraffic(packet []byte, pTypeLen int) {
|
|||
if to == nil {
|
||||
return
|
||||
}
|
||||
newTTLSlice := wire_encode_uint64(newTTL)
|
||||
newTTLLen := wire_uint64_len(newTTL)
|
||||
// This mutates the packet in-place if the length of the TTL changes!
|
||||
shift := ttlLen - len(newTTLSlice)
|
||||
copy(packet[ttlBegin+shift:], newTTLSlice)
|
||||
shift := ttlLen - newTTLLen
|
||||
wire_put_uint64(newTTL, packet[ttlBegin+shift:])
|
||||
copy(packet[shift:], packet[:pTypeLen])
|
||||
packet = packet[shift:]
|
||||
to.sendPacket(packet)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue