mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2024-11-27 12:05:23 +00:00
update ironwood, only store 1 packet in the pre-session buffer
This commit is contained in:
parent
b34c3230f8
commit
1bf751a474
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module github.com/yggdrasil-network/yggdrasil-go
|
|||||||
go 1.16
|
go 1.16
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/Arceliar/ironwood v0.0.0-20210613152842-297306b677cc
|
github.com/Arceliar/ironwood v0.0.0-20210619124114-6ad55cae5031
|
||||||
github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979
|
github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979
|
||||||
github.com/VividCortex/ewma v1.2.0 // indirect
|
github.com/VividCortex/ewma v1.2.0 // indirect
|
||||||
github.com/cheggaaa/pb/v3 v3.0.8
|
github.com/cheggaaa/pb/v3 v3.0.8
|
||||||
|
4
go.sum
4
go.sum
@ -1,5 +1,5 @@
|
|||||||
github.com/Arceliar/ironwood v0.0.0-20210613152842-297306b677cc h1:0eUsfi0FBobUVaBJEcC5x2/Y7Geq7Mpvx51rWmZN7NU=
|
github.com/Arceliar/ironwood v0.0.0-20210619124114-6ad55cae5031 h1:DZVDfYhVdu+0wAiRHoY1olyNkKxIot9UjBnbQFzuUlM=
|
||||||
github.com/Arceliar/ironwood v0.0.0-20210613152842-297306b677cc/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk=
|
github.com/Arceliar/ironwood v0.0.0-20210619124114-6ad55cae5031/go.mod h1:RP72rucOFm5udrnEzTmIWLRVGQiV/fSUAQXJ0RST/nk=
|
||||||
github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979 h1:WndgpSW13S32VLQ3ugUxx2EnnWmgba1kCqPkd4Gk1yQ=
|
github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979 h1:WndgpSW13S32VLQ3ugUxx2EnnWmgba1kCqPkd4Gk1yQ=
|
||||||
github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979/go.mod h1:6Lkn+/zJilRMsKmbmG1RPoamiArC6HS73xbwRyp3UyI=
|
github.com/Arceliar/phony v0.0.0-20210209235338-dde1a8dca979/go.mod h1:6Lkn+/zJilRMsKmbmG1RPoamiArC6HS73xbwRyp3UyI=
|
||||||
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
|
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
|
||||||
|
@ -40,7 +40,7 @@ type keyInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type buffer struct {
|
type buffer struct {
|
||||||
packets [][]byte
|
packet []byte
|
||||||
timeout *time.Timer
|
timeout *time.Timer
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ func (k *keyStore) sendToAddress(addr address.Address, bs []byte) {
|
|||||||
k.addrBuffer[addr] = buf
|
k.addrBuffer[addr] = buf
|
||||||
}
|
}
|
||||||
msg := append([]byte(nil), bs...)
|
msg := append([]byte(nil), bs...)
|
||||||
buf.packets = append(buf.packets, msg)
|
buf.packet = msg
|
||||||
if buf.timeout != nil {
|
if buf.timeout != nil {
|
||||||
buf.timeout.Stop()
|
buf.timeout.Stop()
|
||||||
}
|
}
|
||||||
@ -102,7 +102,7 @@ func (k *keyStore) sendToSubnet(subnet address.Subnet, bs []byte) {
|
|||||||
k.subnetBuffer[subnet] = buf
|
k.subnetBuffer[subnet] = buf
|
||||||
}
|
}
|
||||||
msg := append([]byte(nil), bs...)
|
msg := append([]byte(nil), bs...)
|
||||||
buf.packets = append(buf.packets, msg)
|
buf.packet = msg
|
||||||
if buf.timeout != nil {
|
if buf.timeout != nil {
|
||||||
buf.timeout.Stop()
|
buf.timeout.Stop()
|
||||||
}
|
}
|
||||||
@ -134,15 +134,11 @@ func (k *keyStore) update(key ed25519.PublicKey) *keyInfo {
|
|||||||
k.resetTimeout(info)
|
k.resetTimeout(info)
|
||||||
k.mutex.Unlock()
|
k.mutex.Unlock()
|
||||||
if buf := k.addrBuffer[info.address]; buf != nil {
|
if buf := k.addrBuffer[info.address]; buf != nil {
|
||||||
for _, bs := range buf.packets {
|
k.core.pc.WriteTo(buf.packet, iwt.Addr(info.key[:]))
|
||||||
_, _ = k.core.pc.WriteTo(bs, iwt.Addr(info.key[:]))
|
|
||||||
}
|
|
||||||
delete(k.addrBuffer, info.address)
|
delete(k.addrBuffer, info.address)
|
||||||
}
|
}
|
||||||
if buf := k.subnetBuffer[info.subnet]; buf != nil {
|
if buf := k.subnetBuffer[info.subnet]; buf != nil {
|
||||||
for _, bs := range buf.packets {
|
k.core.pc.WriteTo(buf.packet, iwt.Addr(info.key[:]))
|
||||||
_, _ = k.core.pc.WriteTo(bs, iwt.Addr(info.key[:]))
|
|
||||||
}
|
|
||||||
delete(k.subnetBuffer, info.subnet)
|
delete(k.subnetBuffer, info.subnet)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user