wgengine/magicsock: remove peerMap.byDiscoKey map

No longer used.

Updates #3088

Change-Id: I0ced3f87baa4053d3838d3c4a828ed0293923825
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
(cherry picked from commit c30fa5903d)
This commit is contained in:
Brad Fitzpatrick 2021-10-18 15:31:08 -07:00
parent 6c0723fbd6
commit dc9a2909ac

View File

@ -92,7 +92,6 @@ func newPeerInfo(ep *endpoint) *peerInfo {
//
// Doesn't do any locking, all access must be done with Conn.mu held.
type peerMap struct {
byDiscoKey map[tailcfg.DiscoKey]*peerInfo
byNodeKey map[tailcfg.NodeKey]*peerInfo
byIPPort map[netaddr.IPPort]*peerInfo
@ -103,7 +102,6 @@ type peerMap struct {
func newPeerMap() peerMap {
return peerMap{
byDiscoKey: map[tailcfg.DiscoKey]*peerInfo{},
byNodeKey: map[tailcfg.NodeKey]*peerInfo{},
byIPPort: map[netaddr.IPPort]*peerInfo{},
nodesOfDisco: map[tailcfg.DiscoKey]map[tailcfg.NodeKey]bool{},
@ -118,8 +116,7 @@ func (m *peerMap) nodeCount() int {
// anyEndpointForDiscoKey reports whether there exists any
// peers in the netmap with dk as their DiscoKey.
func (m *peerMap) anyEndpointForDiscoKey(dk tailcfg.DiscoKey) bool {
_, ok := m.byDiscoKey[dk]
return ok
return len(m.nodesOfDisco[dk]) > 0
}
// endpointForNodeKey returns the endpoint for nk, or nil if
@ -179,12 +176,10 @@ func (m *peerMap) upsertEndpoint(ep *endpoint) {
old := pi.ep
pi.ep = ep
if old.discoKey != ep.discoKey {
delete(m.byDiscoKey, old.discoKey)
delete(m.nodesOfDisco[old.discoKey], ep.publicKey)
}
}
if !ep.discoKey.IsZero() {
m.byDiscoKey[ep.discoKey] = pi
set := m.nodesOfDisco[ep.discoKey]
if set == nil {
set = map[tailcfg.NodeKey]bool{}
@ -219,7 +214,6 @@ func (m *peerMap) deleteEndpoint(ep *endpoint) {
}
ep.stopAndReset()
pi := m.byNodeKey[ep.publicKey]
delete(m.byDiscoKey, ep.discoKey)
delete(m.nodesOfDisco[ep.discoKey], ep.publicKey)
delete(m.byNodeKey, ep.publicKey)
if pi == nil {