diff --git a/network/conn.go b/network/conn.go index e1b6d56..6d59afc 100644 --- a/network/conn.go +++ b/network/conn.go @@ -63,5 +63,5 @@ type ConnMultiaddrs interface { // ConnStat is an interface mixin for connection types that provide connection statistics. type ConnStat interface { // Stat stores metadata pertaining to this conn. - Stat() Stat + Stat() ConnStats } diff --git a/network/network.go b/network/network.go index a2ed8d7..3b8550e 100644 --- a/network/network.go +++ b/network/network.go @@ -96,8 +96,15 @@ func (r Reachability) String() string { return str[r] } -// Stat stores metadata pertaining to a given Stream/Conn. -type Stat struct { +// ConnStats stores metadata pertaining to a given Conn. +type ConnStats struct { + Stats + // NumStreams is the number of streams on the connection. + NumStreams int +} + +// Stats stores metadata pertaining to a given Stream / Conn. +type Stats struct { // Direction specifies whether this is an inbound or an outbound connection. Direction Direction // Opened is the timestamp when this connection was opened. diff --git a/network/stream.go b/network/stream.go index c209bb0..c832c12 100644 --- a/network/stream.go +++ b/network/stream.go @@ -21,7 +21,7 @@ type Stream interface { SetProtocol(id protocol.ID) // Stat returns metadata pertaining to this stream. - Stat() Stat + Stat() Stats // Conn returns the connection this stream is part of. Conn() Conn