9 pieceHash = crypto.SHA1
10 maxRequests = 250 // Maximum pending requests we allow peers to send us.
11 defaultChunkSize = 0x4000 // 16KiB
13 // Justification for set bits follows.
15 // Extension protocol ([5]|=0x10):
16 // http://www.bittorrent.org/beps/bep_0010.html
18 // Fast Extension ([7]|=0x04):
19 // http://bittorrent.org/beps/bep_0006.html.
20 // Disabled until AllowedFast is implemented. TODO
23 // http://www.bittorrent.org/beps/bep_0005.html
24 defaultExtensionBytes = "\x00\x00\x00\x00\x00\x10\x00\x01"
26 // These are our extended message IDs. Peers will use these values to
27 // select which extension a message is intended for.
28 metadataExtendedId = iota + 1 // 0 is reserved for deleting keys
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 unwantedChunksReceived = expvar.NewInt("chunksReceivedUnwanted")
36 unexpectedChunksReceived = expvar.NewInt("chunksReceivedUnexpected")
37 chunksReceived = expvar.NewInt("chunksReceived")
39 peersAddedBySource = expvar.NewMap("peersAddedBySource")
41 uploadChunksPosted = expvar.NewInt("uploadChunksPosted")
42 unexpectedCancels = expvar.NewInt("unexpectedCancels")
44 pieceHashedCorrect = expvar.NewInt("pieceHashedCorrect")
45 pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
47 unsuccessfulDials = expvar.NewInt("dialSuccessful")
48 successfulDials = expvar.NewInt("dialUnsuccessful")
50 acceptUTP = expvar.NewInt("acceptUTP")
51 acceptTCP = expvar.NewInt("acceptTCP")
52 acceptReject = expvar.NewInt("acceptReject")
54 peerExtensions = expvar.NewMap("peerExtensions")
55 completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
56 // Count of connections to peer with same client ID.
57 connsToSelf = expvar.NewInt("connsToSelf")
58 // Number of completed connections to a client we're already connected with.
59 duplicateClientConns = expvar.NewInt("duplicateClientConns")
60 receivedKeepalives = expvar.NewInt("receivedKeepalives")
61 supportedExtensionMessages = expvar.NewMap("supportedExtensionMessages")
62 postedKeepalives = expvar.NewInt("postedKeepalives")
63 // Requests received for pieces we don't have.
64 requestsReceivedForMissingPieces = expvar.NewInt("requestsReceivedForMissingPieces")
66 messageTypesReceived = expvar.NewMap("messageTypesReceived")
67 messageTypesSent = expvar.NewMap("messageTypesSent")
68 messageTypesPosted = expvar.NewMap("messageTypesPosted")
70 // Track the effectiveness of Torrent.connPieceInclinationPool.
71 pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused")
72 pieceInclinationsNew = expvar.NewInt("pieceInclinationsNew")
73 pieceInclinationsPut = expvar.NewInt("pieceInclinationsPut")
75 fillBufferSentCancels = expvar.NewInt("fillBufferSentCancels")
76 fillBufferSentRequests = expvar.NewInt("fillBufferSentRequests")
77 numFillBuffers = expvar.NewInt("numFillBuffers")