Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Commit

Permalink
Merge branch '1731-merge-peer-has-short-id' into remove-unknown-peer-…
Browse files Browse the repository at this point in the history
…error
  • Loading branch information
rade committed Nov 30, 2015
2 parents 068bbe0 + 9dee2f2 commit dffbc75
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mesh/peers.go
Original file line number Diff line number Diff line change
Expand Up @@ -476,16 +476,20 @@ func (peers *Peers) applyUpdate(decodedUpdate []*Peer, decodedConns [][]Connecti
newUpdate[name] = void
default: // existing peer
if newPeer.Version < peer.Version ||
(newPeer.Version == peer.Version && newPeer.UID <= peer.UID) {
(newPeer.Version == peer.Version &&
(newPeer.UID < peer.UID ||
(newPeer.UID == peer.UID &&
(!newPeer.HasShortID || peer.HasShortID)))) {
continue
}
peer.Version = newPeer.Version
peer.UID = newPeer.UID
peer.connections = makeConnsMap(peer, connSummaries, peers.byName)

if newPeer.ShortID != peer.ShortID {
if newPeer.ShortID != peer.ShortID || newPeer.HasShortID != peer.HasShortID {
peers.deleteByShortID(peer, pending)
peer.ShortID = newPeer.ShortID
peer.HasShortID = newPeer.HasShortID
peers.addByShortID(peer, pending)
}
newUpdate[name] = void
Expand Down

0 comments on commit dffbc75

Please sign in to comment.