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 unwantedChunksReceived = expvar.NewInt("chunksReceivedUnwanted")
27 unexpectedChunksReceived = expvar.NewInt("chunksReceivedUnexpected")
28 chunksReceived = expvar.NewInt("chunksReceived")
30 torrent = expvar.NewMap("torrent")
32 peersAddedBySource = expvar.NewMap("peersAddedBySource")
34 pieceHashedCorrect = expvar.NewInt("pieceHashedCorrect")
35 pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
37 unsuccessfulDials = expvar.NewInt("dialSuccessful")
38 successfulDials = expvar.NewInt("dialUnsuccessful")
40 acceptUTP = expvar.NewInt("acceptUTP")
41 acceptTCP = expvar.NewInt("acceptTCP")
42 acceptReject = expvar.NewInt("acceptReject")
44 peerExtensions = expvar.NewMap("peerExtensions")
45 completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
46 // Count of connections to peer with same client ID.
47 connsToSelf = expvar.NewInt("connsToSelf")
48 // Number of completed connections to a client we're already connected with.
49 duplicateClientConns = expvar.NewInt("duplicateClientConns")
50 receivedKeepalives = expvar.NewInt("receivedKeepalives")
51 supportedExtensionMessages = expvar.NewMap("supportedExtensionMessages")
52 postedKeepalives = expvar.NewInt("postedKeepalives")
53 // Requests received for pieces we don't have.
54 requestsReceivedForMissingPieces = expvar.NewInt("requestsReceivedForMissingPieces")
55 requestedChunkLengths = expvar.NewMap("requestedChunkLengths")
57 messageTypesReceived = expvar.NewMap("messageTypesReceived")
58 messageTypesSent = expvar.NewMap("messageTypesSent")
59 messageTypesPosted = expvar.NewMap("messageTypesPosted")
61 // Track the effectiveness of Torrent.connPieceInclinationPool.
62 pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused")
63 pieceInclinationsNew = expvar.NewInt("pieceInclinationsNew")
64 pieceInclinationsPut = expvar.NewInt("pieceInclinationsPut")
66 fillBufferSentCancels = expvar.NewInt("fillBufferSentCancels")
67 fillBufferSentRequests = expvar.NewInt("fillBufferSentRequests")
68 numFillBuffers = expvar.NewInt("numFillBuffers")