]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Move expvars into expvar.go
authorMatt Joiner <anacrolix@gmail.com>
Wed, 4 Jun 2025 00:24:56 +0000 (10:24 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Wed, 4 Jun 2025 00:24:56 +0000 (10:24 +1000)
expvar.go [new file with mode: 0644]
global.go

diff --git a/expvar.go b/expvar.go
new file mode 100644 (file)
index 0000000..2a1f386
--- /dev/null
+++ b/expvar.go
@@ -0,0 +1,35 @@
+package torrent
+
+import (
+       "expvar"
+)
+
+func init() {
+       torrent.Set("peers supporting extension", &peersSupportingExtension)
+       torrent.Set("chunks received", &ChunksReceived)
+}
+
+// I could move a lot of these counters to their own file, but I suspect they
+// may be attached to a Client someday.
+var (
+       torrent                  = expvar.NewMap("torrent")
+       peersSupportingExtension expvar.Map
+       // This could move at any time. It contains counts of chunks received and the conditions they
+       // were received.
+       ChunksReceived expvar.Map
+
+       pieceHashedCorrect    = expvar.NewInt("pieceHashedCorrect")
+       pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
+
+       completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
+       // Count of connections to peer with same client ID.
+       connsToSelf        = expvar.NewInt("connsToSelf")
+       receivedKeepalives = expvar.NewInt("receivedKeepalives")
+       // Requests received for pieces we don't have.
+       requestsReceivedForMissingPieces = expvar.NewInt("requestsReceivedForMissingPieces")
+       requestedChunkLengths            = expvar.NewMap("requestedChunkLengths")
+
+       messageTypesReceived = expvar.NewMap("messageTypesReceived")
+
+       concurrentChunkWrites = expvar.NewInt("torrentConcurrentChunkWrites")
+)
index b0c1ce4abc3a98653b8c9d1817fdd13891351a0d..436c84f64e6fdb4712ddfeb71db246702b3e4e6e 100644 (file)
--- a/global.go
+++ b/global.go
@@ -2,7 +2,6 @@ package torrent
 
 import (
        "crypto"
-       "expvar"
 
        pp "github.com/anacrolix/torrent/peer_protocol"
 )
@@ -22,33 +21,3 @@ const (
 func defaultPeerExtensionBytes() PeerExtensionBits {
        return pp.NewPeerExtensionBytes(pp.ExtensionBitDht, pp.ExtensionBitLtep, pp.ExtensionBitFast)
 }
-
-func init() {
-       torrent.Set("peers supporting extension", &peersSupportingExtension)
-       torrent.Set("chunks received", &ChunksReceived)
-}
-
-// I could move a lot of these counters to their own file, but I suspect they
-// may be attached to a Client someday.
-var (
-       torrent                  = expvar.NewMap("torrent")
-       peersSupportingExtension expvar.Map
-       // This could move at any time. It contains counts of chunks received and the conditions they
-       // were received.
-       ChunksReceived expvar.Map
-
-       pieceHashedCorrect    = expvar.NewInt("pieceHashedCorrect")
-       pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
-
-       completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
-       // Count of connections to peer with same client ID.
-       connsToSelf        = expvar.NewInt("connsToSelf")
-       receivedKeepalives = expvar.NewInt("receivedKeepalives")
-       // Requests received for pieces we don't have.
-       requestsReceivedForMissingPieces = expvar.NewInt("requestsReceivedForMissingPieces")
-       requestedChunkLengths            = expvar.NewMap("requestedChunkLengths")
-
-       messageTypesReceived = expvar.NewMap("messageTypesReceived")
-
-       concurrentChunkWrites = expvar.NewInt("torrentConcurrentChunkWrites")
-)