]> Sergey Matveev's repositories - btrtrc.git/blob - global.go
Track peers supporting extension in a nested expvar.Map
[btrtrc.git] / global.go
1 package torrent
2
3 import (
4         "crypto"
5         "expvar"
6
7         pp "github.com/anacrolix/torrent/peer_protocol"
8 )
9
10 const (
11         pieceHash        = crypto.SHA1
12         maxRequests      = 250    // Maximum pending requests we allow peers to send us.
13         defaultChunkSize = 0x4000 // 16KiB
14 )
15
16 // These are our extended message IDs. Peers will use these values to
17 // select which extension a message is intended for.
18 const (
19         metadataExtendedId = iota + 1 // 0 is reserved for deleting keys
20         pexExtendedId
21 )
22
23 func defaultPeerExtensionBytes() PeerExtensionBits {
24         return pp.NewPeerExtensionBytes(pp.ExtensionBitDHT, pp.ExtensionBitExtended, pp.ExtensionBitFast)
25 }
26
27 func init() {
28         torrent.Set("peers supporting extension", &peersSupportingExtension)
29 }
30
31 // I could move a lot of these counters to their own file, but I suspect they
32 // may be attached to a Client someday.
33 var (
34         torrent                  = expvar.NewMap("torrent")
35         peersSupportingExtension expvar.Map
36
37         pieceHashedCorrect    = expvar.NewInt("pieceHashedCorrect")
38         pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
39
40         completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
41         // Count of connections to peer with same client ID.
42         connsToSelf        = expvar.NewInt("connsToSelf")
43         receivedKeepalives = expvar.NewInt("receivedKeepalives")
44         // Requests received for pieces we don't have.
45         requestsReceivedForMissingPieces = expvar.NewInt("requestsReceivedForMissingPieces")
46         requestedChunkLengths            = expvar.NewMap("requestedChunkLengths")
47
48         messageTypesReceived = expvar.NewMap("messageTypesReceived")
49
50         // Track the effectiveness of Torrent.connPieceInclinationPool.
51         pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused")
52         pieceInclinationsNew    = expvar.NewInt("pieceInclinationsNew")
53         pieceInclinationsPut    = expvar.NewInt("pieceInclinationsPut")
54
55         concurrentChunkWrites = expvar.NewInt("torrentConcurrentChunkWrites")
56 )