aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/metrics.go
diff options
context:
space:
mode:
Diffstat (limited to 'p2p/metrics.go')
-rw-r--r--p2p/metrics.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/p2p/metrics.go b/p2p/metrics.go
index f98cac274..98b61901d 100644
--- a/p2p/metrics.go
+++ b/p2p/metrics.go
@@ -38,8 +38,14 @@ type meteredConn struct {
}
// newMeteredConn creates a new metered connection, also bumping the ingress or
-// egress connection meter.
+// egress connection meter. If the metrics system is disabled, this function
+// returns the original object.
func newMeteredConn(conn net.Conn, ingress bool) net.Conn {
+ // Short circuit if metrics are disabled
+ if !metrics.Enabled {
+ return conn
+ }
+ // Otherwise bump the connection counters and wrap the connection
if ingress {
ingressConnectMeter.Mark(1)
} else {