]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Expose Client.ConnStats
authorMatt Joiner <anacrolix@gmail.com>
Thu, 1 Oct 2020 01:20:44 +0000 (11:20 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 1 Oct 2020 01:20:44 +0000 (11:20 +1000)
client.go

index 7ae72295da5f38e8c20fd7ee681b46314f984b8a..682cf8361850012b50118f49098765e71db57b26 100644 (file)
--- 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()
+}