From ed7a5ab43233d246adca2e67c29f194aaa850d10 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Sun, 12 Dec 2021 14:58:02 +0400 Subject: [PATCH] rename network.Stat to Stats, introduce ConnStats (#226) --- network/conn.go | 2 +- network/network.go | 11 +++++++++-- network/stream.go | 2 +- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/network/conn.go b/network/conn.go index e1b6d561..6d59afcc 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 a2ed8d72..3b8550ee 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 c209bb08..c832c127 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