From 3d7ac87e3b8ec005a303e4e9082675c3c7aab2b7 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Thu, 1 Oct 2020 11:20:44 +1000 Subject: [PATCH] Expose Client.ConnStats --- client.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/client.go b/client.go index 7ae72295..682cf836 100644 --- a/client.go +++ b/client.go @@ -47,8 +47,8 @@ import ( // Clients contain zero or more Torrents. A Client manages a blocklist, the // TCP/UDP protocol ports, and DHT as desired. type Client struct { - // An aggregate of stats over all connections. First in struct to ensure - // 64-bit alignment of fields. See #262. + // An aggregate of stats over all connections. First in struct to ensure 64-bit alignment of + // fields. See #262. stats ConnStats _mu lockWithDeferreds @@ -1516,3 +1516,9 @@ func (cl *Client) locker() *lockWithDeferreds { func (cl *Client) String() string { return fmt.Sprintf("<%[1]T %[1]p>", cl) } + +// Returns connection-level aggregate stats at the Client level. See the comment on +// TorrentStats.ConnStats. +func (cl *Client) ConnStats() ConnStats { + return cl.stats.Copy() +} -- 2.48.1