7 pp "github.com/anacrolix/torrent/peer_protocol"
11 pieceHash = crypto.SHA1
12 maxRequests = 250 // Maximum pending requests we allow peers to send us.
13 defaultChunkSize = 0x4000 // 16KiB
16 // These are our extended message IDs. Peers will use these values to
17 // select which extension a message is intended for.
19 metadataExtendedId = iota + 1 // 0 is reserved for deleting keys
23 func defaultPeerExtensionBytes() PeerExtensionBits {
24 return pp.NewPeerExtensionBytes(pp.ExtensionBitDHT, pp.ExtensionBitExtended, pp.ExtensionBitFast)
28 torrent.Set("peers supporting extension", &peersSupportingExtension)
29 torrent.Set("chunks received", &chunksReceived)
32 // I could move a lot of these counters to their own file, but I suspect they
33 // may be attached to a Client someday.
35 torrent = expvar.NewMap("torrent")
36 peersSupportingExtension expvar.Map
37 chunksReceived expvar.Map
39 pieceHashedCorrect = expvar.NewInt("pieceHashedCorrect")
40 pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
42 completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
43 // Count of connections to peer with same client ID.
44 connsToSelf = expvar.NewInt("connsToSelf")
45 receivedKeepalives = expvar.NewInt("receivedKeepalives")
46 // Requests received for pieces we don't have.
47 requestsReceivedForMissingPieces = expvar.NewInt("requestsReceivedForMissingPieces")
48 requestedChunkLengths = expvar.NewMap("requestedChunkLengths")
50 messageTypesReceived = expvar.NewMap("messageTypesReceived")
52 // Track the effectiveness of Torrent.connPieceInclinationPool.
53 pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused")
54 pieceInclinationsNew = expvar.NewInt("pieceInclinationsNew")
55 pieceInclinationsPut = expvar.NewInt("pieceInclinationsPut")
57 concurrentChunkWrites = expvar.NewInt("torrentConcurrentChunkWrites")