mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 14:15:06 +03:00
make the switch react to peer coord changes immediately, and send out updates immediately
This commit is contained in:
parent
85afe187ff
commit
ecf37cae8a
2 changed files with 46 additions and 15 deletions
|
@ -223,12 +223,14 @@ func (t *switchTable) cleanRoot() {
|
|||
}
|
||||
t.data.locator = switchLocator{root: t.key, tstamp: now.Unix()}
|
||||
t.data.sigs = nil
|
||||
t.core.peers.sendSwitchMsgs()
|
||||
}
|
||||
}
|
||||
|
||||
func (t *switchTable) removePeer(port switchPort) {
|
||||
delete(t.data.peers, port)
|
||||
t.updater.Store(&sync.Once{})
|
||||
t.core.peers.fixSwitchAfterPeerDisconnect()
|
||||
}
|
||||
|
||||
func (t *switchTable) cleanDropped() {
|
||||
|
@ -250,6 +252,7 @@ func (t *switchTable) createMessage(port switchPort) (*switchMessage, []sigInfo)
|
|||
}
|
||||
|
||||
func (t *switchTable) handleMessage(msg *switchMessage, fromPort switchPort, sigs []sigInfo) {
|
||||
// TODO directly use a switchMsg instead of switchMessage + sigs
|
||||
t.mutex.Lock()
|
||||
defer t.mutex.Unlock()
|
||||
now := time.Now()
|
||||
|
@ -344,6 +347,7 @@ func (t *switchTable) handleMessage(msg *switchMessage, fromPort switchPort, sig
|
|||
t.parent = sender.port
|
||||
t.data.sigs = sigs
|
||||
//t.core.log.Println("Switch update:", msg.Locator.Root, msg.Locator.Tstamp, msg.Locator.Coords)
|
||||
t.core.peers.sendSwitchMsgs()
|
||||
}
|
||||
if doUpdate {
|
||||
t.updater.Store(&sync.Once{})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue