mirror of
https://github.com/tailscale/tailscale.git
synced 2025-10-15 10:49:18 +00:00
all: use set.Set consistently instead of map[T]struct{}
I didn't clean up the more idiomatic map[T]bool with true values, at least yet. I just converted the relatively awkward struct{}-valued maps. Updates #cleanup Change-Id: I758abebd2bb1f64bc7a9d0f25c32298f4679c14f Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
This commit is contained in:

committed by
Brad Fitzpatrick

parent
d506a55c8a
commit
dc7aa98b76
@@ -54,6 +54,7 @@ import (
|
||||
"tailscale.com/util/clientmetric"
|
||||
"tailscale.com/util/mak"
|
||||
"tailscale.com/util/ringbuffer"
|
||||
"tailscale.com/util/set"
|
||||
"tailscale.com/util/uniq"
|
||||
"tailscale.com/wgengine/capture"
|
||||
)
|
||||
@@ -229,7 +230,7 @@ type Conn struct {
|
||||
// WireGuard. These are not used to filter inbound or outbound
|
||||
// traffic at all, but only to track what state can be cleaned up
|
||||
// in other maps below that are keyed by peer public key.
|
||||
peerSet map[key.NodePublic]struct{}
|
||||
peerSet set.Set[key.NodePublic]
|
||||
|
||||
// nodeOfDisco tracks the networkmap Node entity for each peer
|
||||
// discovery key.
|
||||
@@ -1708,7 +1709,7 @@ func (c *Conn) SetPrivateKey(privateKey key.NodePrivate) error {
|
||||
// then removes any state for old peers.
|
||||
//
|
||||
// The caller passes ownership of newPeers map to UpdatePeers.
|
||||
func (c *Conn) UpdatePeers(newPeers map[key.NodePublic]struct{}) {
|
||||
func (c *Conn) UpdatePeers(newPeers set.Set[key.NodePublic]) {
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
|
||||
@@ -1718,7 +1719,7 @@ func (c *Conn) UpdatePeers(newPeers map[key.NodePublic]struct{}) {
|
||||
// Clean up any key.NodePublic-keyed maps for peers that no longer
|
||||
// exist.
|
||||
for peer := range oldPeers {
|
||||
if _, ok := newPeers[peer]; !ok {
|
||||
if !newPeers.Contains(peer) {
|
||||
delete(c.derpRoute, peer)
|
||||
delete(c.peerLastDerp, peer)
|
||||
}
|
||||
|
Reference in New Issue
Block a user