diff --git a/p2p/peer_test.go b/p2p/peer_test.go index 7569f1281..ddfeb4234 100644 --- a/p2p/peer_test.go +++ b/p2p/peer_test.go @@ -4,8 +4,6 @@ import ( "fmt" golog "log" "net" - "reflect" - "sync" "testing" "time" @@ -100,12 +98,8 @@ func createOutboundPeerAndPerformHandshake( if err != nil { return nil, err } - mlc := &metricsLabelCache{ - mtx: &sync.RWMutex{}, - messageLabelNames: make(map[reflect.Type]string), - } - p := newPeer(pc, mConfig, peerNodeInfo, reactorsByCh, msgTypeByChID, chDescs, func(p Peer, r interface{}) {}, mlc) + p := newPeer(pc, mConfig, peerNodeInfo, reactorsByCh, msgTypeByChID, chDescs, func(p Peer, r interface{}) {}, newMetricsLabelCache()) p.SetLogger(log.TestingLogger().With("peer", addr)) return p, nil } diff --git a/p2p/switch.go b/p2p/switch.go index b0ba71fcc..adf1a396c 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -3,7 +3,6 @@ package p2p import ( "fmt" "math" - "reflect" "sync" "time" @@ -111,10 +110,7 @@ func NewSwitch( transport Transport, options ...SwitchOption, ) *Switch { - mlc := &metricsLabelCache{ - mtx: &sync.RWMutex{}, - messageLabelNames: make(map[reflect.Type]string), - } + sw := &Switch{ config: cfg, reactors: make(map[string]Reactor), @@ -129,7 +125,7 @@ func NewSwitch( filterTimeout: defaultFilterTimeout, persistentPeersAddrs: make([]*NetAddress, 0), unconditionalPeerIDs: make(map[ID]struct{}), - mlc: mlc, + mlc: newMetricsLabelCache(), } // Ensure we have a completely undeterministic PRNG.