mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2026-05-22 05:46:30 +03:00
update switch blockPeer/unblockPeer logic and dht reset when coords change
This commit is contained in:
@@ -194,21 +194,20 @@ func (ps *peers) sendSwitchMsgs(from phony.Actor) {
|
||||
})
|
||||
}
|
||||
|
||||
// This must be launched in a separate goroutine by whatever sets up the peer struct.
|
||||
// It handles link protocol traffic.
|
||||
func (p *peer) start() {
|
||||
var updateDHT func()
|
||||
updateDHT = func() {
|
||||
phony.Block(p, func() {
|
||||
select {
|
||||
case <-p.done:
|
||||
default:
|
||||
p._updateDHT()
|
||||
time.AfterFunc(time.Second, updateDHT)
|
||||
func (ps *peers) updateDHT(from phony.Actor) {
|
||||
ps.Act(from, func() {
|
||||
for _, peer := range ps.ports {
|
||||
p := peer
|
||||
if p.port == 0 {
|
||||
continue
|
||||
}
|
||||
})
|
||||
}
|
||||
updateDHT()
|
||||
p.Act(ps, p._updateDHT)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// This must be launched in a separate goroutine by whatever sets up the peer struct.
|
||||
func (p *peer) start() {
|
||||
// Just for good measure, immediately send a switch message to this peer when we start
|
||||
p.Act(nil, p._sendSwitchMsg)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user