From: Matt Joiner <anacrolix@gmail.com>
Date: Thu, 1 Oct 2020 01:20:44 +0000 (+1000)
Subject: Expose Client.ConnStats
X-Git-Tag: v1.17.0~3
X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=3d7ac87e3b8ec005a303e4e9082675c3c7aab2b7;p=btrtrc.git

Expose Client.ConnStats
---

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()
+}