From c51e153b5c5327f971e7b410e49e7babfc3f0b8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Szil=C3=A1gyi?= Date: Thu, 2 Jul 2015 14:13:46 +0300 Subject: eth, metrics, p2p: prepare metrics and net packets to eth/62 --- p2p/metrics.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'p2p') 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 { -- cgit v1.2.3