aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/metrics.go
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2015-07-02 19:13:46 +0800
committerPéter Szilágyi <peterke@gmail.com>2015-08-21 15:30:57 +0800
commitc51e153b5c5327f971e7b410e49e7babfc3f0b8e (patch)
tree3a2f25a668a887fcb1026ae323480ac5fda3548a /p2p/metrics.go
parentd51d0022cee91d6588186455afbe6e54fae2cbf7 (diff)
downloaddexon-c51e153b5c5327f971e7b410e49e7babfc3f0b8e.tar.gz
dexon-c51e153b5c5327f971e7b410e49e7babfc3f0b8e.tar.zst
dexon-c51e153b5c5327f971e7b410e49e7babfc3f0b8e.zip
eth, metrics, p2p: prepare metrics and net packets to eth/62
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 {