From b888ace508729031e0ff3953bdf777e76c893df9 Mon Sep 17 00:00:00 2001 From: Matthias Radestock Date: Thu, 22 Oct 2015 16:12:37 +0100 Subject: [PATCH] remove superfluous code in ApplyUpdate If the local peer's short ID was updated, we broadcastPeerUpdate at the end (in unlockAndNotify), so there is no need to include the local peer in the current update. Also, reading peers.ourself.Version is bad here - we don't take a lock and it's written by other goroutines. Doesn't actually break anything though since it's a uint64 and hence atomic. --- router/peers.go | 9 --------- 1 file changed, 9 deletions(-) diff --git a/router/peers.go b/router/peers.go index 098a7825..f3d238d0 100644 --- a/router/peers.go +++ b/router/peers.go @@ -327,8 +327,6 @@ func (peers *Peers) ApplyUpdate(update []byte) (PeerNameSet, PeerNameSet, error) return nil, nil, err } - ourVersion := peers.ourself.Version - // By this point, we know the update doesn't refer to any peers we // have no knowledge of. We can now apply the update. Start by // adding in any new peers. @@ -349,13 +347,6 @@ func (peers *Peers) ApplyUpdate(update []byte) (PeerNameSet, PeerNameSet, error) updateNames[peer.Name] = void } - if peers.ourself.Version != ourVersion { - // Our short id changed, i.e. due to a short ID - // change. So we need to include ourself in the - // update - newUpdate[peers.ourself.Name] = void - } - return updateNames, newUpdate, nil }