9 pieceHash = crypto.SHA1
10 maxRequests = 250 // Maximum pending requests we allow peers to send us.
11 defaultChunkSize = 0x4000 // 16KiB
13 // These are our extended message IDs. Peers will use these values to
14 // select which extension a message is intended for.
15 metadataExtendedId = iota + 1 // 0 is reserved for deleting keys
19 func defaultPeerExtensionBytes() peerExtensionBytes {
20 return newPeerExtensionBytes(ExtensionBitDHT, ExtensionBitExtended, ExtensionBitFast)
23 // I could move a lot of these counters to their own file, but I suspect they
24 // may be attached to a Client someday.
26 torrent = expvar.NewMap("torrent")
28 peersAddedBySource = expvar.NewMap("peersAddedBySource")
30 pieceHashedCorrect = expvar.NewInt("pieceHashedCorrect")
31 pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
33 peerExtensions = expvar.NewMap("peerExtensions")
34 completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
35 // Count of connections to peer with same client ID.
36 connsToSelf = expvar.NewInt("connsToSelf")
37 receivedKeepalives = expvar.NewInt("receivedKeepalives")
38 supportedExtensionMessages = expvar.NewMap("supportedExtensionMessages")
39 postedKeepalives = expvar.NewInt("postedKeepalives")
40 // Requests received for pieces we don't have.
41 requestsReceivedForMissingPieces = expvar.NewInt("requestsReceivedForMissingPieces")
42 requestedChunkLengths = expvar.NewMap("requestedChunkLengths")
44 messageTypesReceived = expvar.NewMap("messageTypesReceived")
45 messageTypesSent = expvar.NewMap("messageTypesSent")
46 messageTypesPosted = expvar.NewMap("messageTypesPosted")
48 // Track the effectiveness of Torrent.connPieceInclinationPool.
49 pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused")
50 pieceInclinationsNew = expvar.NewInt("pieceInclinationsNew")
51 pieceInclinationsPut = expvar.NewInt("pieceInclinationsPut")