aboutsummaryrefslogtreecommitdiffstats
path: root/p2p/metrics.go
diff options
context:
space:
mode:
authorViktor TrĂ³n <viktor.tron@gmail.com>2018-06-22 05:00:43 +0800
committerGitHub <noreply@github.com>2018-06-22 05:00:43 +0800
commiteaff89291ce998ba4bf9b9816ca8a15c8b85f440 (patch)
treec77d7a06627a1a7f578d0fec8e39788e66672e53 /p2p/metrics.go
parentd926bf2c7e3182d694c15829a37a0ca7331cd03c (diff)
parente187711c6545487d4cac3701f0f506bb536234e2 (diff)
downloaddexon-eaff89291ce998ba4bf9b9816ca8a15c8b85f440.tar
dexon-eaff89291ce998ba4bf9b9816ca8a15c8b85f440.tar.gz
dexon-eaff89291ce998ba4bf9b9816ca8a15c8b85f440.tar.bz2
dexon-eaff89291ce998ba4bf9b9816ca8a15c8b85f440.tar.lz
dexon-eaff89291ce998ba4bf9b9816ca8a15c8b85f440.tar.xz
dexon-eaff89291ce998ba4bf9b9816ca8a15c8b85f440.tar.zst
dexon-eaff89291ce998ba4bf9b9816ca8a15c8b85f440.zip
Merge pull request #17041 from ethersphere/swarm-network-rewrite-merge
Swarm POC3 - happy solstice
Diffstat (limited to 'p2p/metrics.go')
-rw-r--r--p2p/metrics.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/p2p/metrics.go b/p2p/metrics.go
index 4cbff90ac..2d52fd1fd 100644
--- a/p2p/metrics.go
+++ b/p2p/metrics.go
@@ -31,10 +31,10 @@ var (
egressTrafficMeter = metrics.NewRegisteredMeter("p2p/OutboundTraffic", nil)
)
-// meteredConn is a wrapper around a network TCP connection that meters both the
+// meteredConn is a wrapper around a net.Conn that meters both the
// inbound and outbound network traffic.
type meteredConn struct {
- *net.TCPConn // Network connection to wrap with metering
+ net.Conn // Network connection to wrap with metering
}
// newMeteredConn creates a new metered connection, also bumping the ingress or
@@ -51,13 +51,13 @@ func newMeteredConn(conn net.Conn, ingress bool) net.Conn {
} else {
egressConnectMeter.Mark(1)
}
- return &meteredConn{conn.(*net.TCPConn)}
+ return &meteredConn{Conn: conn}
}
// Read delegates a network read to the underlying connection, bumping the ingress
// traffic meter along the way.
func (c *meteredConn) Read(b []byte) (n int, err error) {
- n, err = c.TCPConn.Read(b)
+ n, err = c.Conn.Read(b)
ingressTrafficMeter.Mark(int64(n))
return
}
@@ -65,7 +65,7 @@ func (c *meteredConn) Read(b []byte) (n int, err error) {
// Write delegates a network write to the underlying connection, bumping the
// egress traffic meter along the way.
func (c *meteredConn) Write(b []byte) (n int, err error) {
- n, err = c.TCPConn.Write(b)
+ n, err = c.Conn.Write(b)
egressTrafficMeter.Mark(int64(n))
return
}