eth, metrics, p2p: prepare metrics and net packets to eth/62

This commit is contained in:
Péter Szilágyi
2015-07-02 14:13:46 +03:00
parent d51d0022ce
commit c51e153b5c
7 changed files with 149 additions and 48 deletions

View File

@ -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 {