@@ -74,7 +74,7 @@ const (
7474type MeteredPeerEvent struct {
7575 Type MeteredPeerEventType // Type of peer event
7676 IP net.IP // IP address of the peer
77- ID string // NodeID of the peer
77+ ID enode. ID // NodeID of the peer
7878 Elapsed time.Duration // Time elapsed between the connection and the handshake/disconnection
7979 Ingress uint64 // Ingress count at the moment of the event
8080 Egress uint64 // Egress count at the moment of the event
@@ -93,7 +93,7 @@ type meteredConn struct {
9393
9494 connected time.Time // Connection time of the peer
9595 ip net.IP // IP address of the peer
96- id string // NodeID of the peer
96+ id enode. ID // NodeID of the peer
9797
9898 // trafficMetered denotes if the peer is registered in the traffic registries.
9999 // Its value is true if the metered peer count doesn't reach the limit in the
@@ -160,8 +160,7 @@ func (c *meteredConn) Write(b []byte) (n int, err error) {
160160// handshakeDone is called when a peer handshake is done. Registers the peer to
161161// the ingress and the egress traffic registries using the peer's IP and node ID,
162162// also emits connect event.
163- func (c * meteredConn ) handshakeDone (nodeID enode.ID ) {
164- id := nodeID .String ()
163+ func (c * meteredConn ) handshakeDone (id enode.ID ) {
165164 if atomic .AddInt32 (& meteredPeerCount , 1 ) >= MeteredPeerLimit {
166165 // Don't register the peer in the traffic registries.
167166 atomic .AddInt32 (& meteredPeerCount , - 1 )
@@ -170,7 +169,7 @@ func (c *meteredConn) handshakeDone(nodeID enode.ID) {
170169 c .lock .Unlock ()
171170 log .Warn ("Metered peer count reached the limit" )
172171 } else {
173- key := fmt .Sprintf ("%s/%s" , c .ip , id )
172+ key := fmt .Sprintf ("%s/%s" , c .ip , id . String () )
174173 c .lock .Lock ()
175174 c .id , c .trafficMetered = id , true
176175 c .ingressMeter = metrics .NewRegisteredMeter (key , PeerIngressRegistry )
@@ -190,7 +189,7 @@ func (c *meteredConn) handshakeDone(nodeID enode.ID) {
190189func (c * meteredConn ) Close () error {
191190 err := c .Conn .Close ()
192191 c .lock .RLock ()
193- if c .id == "" {
192+ if c .id == (enode. ID {}) {
194193 // If the peer disconnects before the handshake.
195194 c .lock .RUnlock ()
196195 meteredPeerFeed .Send (MeteredPeerEvent {
0 commit comments