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.
This commit is contained in:
1 parent
94d7f33a03
commit
b888ace508
1 file changed
-9
@@ -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
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user