]> Sergey Matveev's repositories - btrtrc.git/blob - global.go
Support AllowedFast and enable fast extension
[btrtrc.git] / global.go
1 package torrent
2
3 import (
4         "crypto"
5         "expvar"
6 )
7
8 const (
9         pieceHash        = crypto.SHA1
10         maxRequests      = 250    // Maximum pending requests we allow peers to send us.
11         defaultChunkSize = 0x4000 // 16KiB
12
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
16         pexExtendedId
17 )
18
19 func defaultPeerExtensionBytes() peerExtensionBytes {
20         return newPeerExtensionBytes(ExtensionBitDHT, ExtensionBitExtended, ExtensionBitFast)
21 }
22
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.
25 var (
26         unwantedChunksReceived   = expvar.NewInt("chunksReceivedUnwanted")
27         unexpectedChunksReceived = expvar.NewInt("chunksReceivedUnexpected")
28         chunksReceived           = expvar.NewInt("chunksReceived")
29
30         torrent = expvar.NewMap("torrent")
31
32         peersAddedBySource = expvar.NewMap("peersAddedBySource")
33
34         uploadChunksPosted = expvar.NewInt("uploadChunksPosted")
35
36         pieceHashedCorrect    = expvar.NewInt("pieceHashedCorrect")
37         pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
38
39         unsuccessfulDials = expvar.NewInt("dialSuccessful")
40         successfulDials   = expvar.NewInt("dialUnsuccessful")
41
42         acceptUTP    = expvar.NewInt("acceptUTP")
43         acceptTCP    = expvar.NewInt("acceptTCP")
44         acceptReject = expvar.NewInt("acceptReject")
45
46         peerExtensions                    = expvar.NewMap("peerExtensions")
47         completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
48         // Count of connections to peer with same client ID.
49         connsToSelf = expvar.NewInt("connsToSelf")
50         // Number of completed connections to a client we're already connected with.
51         duplicateClientConns       = expvar.NewInt("duplicateClientConns")
52         receivedKeepalives         = expvar.NewInt("receivedKeepalives")
53         supportedExtensionMessages = expvar.NewMap("supportedExtensionMessages")
54         postedKeepalives           = expvar.NewInt("postedKeepalives")
55         // Requests received for pieces we don't have.
56         requestsReceivedForMissingPieces = expvar.NewInt("requestsReceivedForMissingPieces")
57         requestedChunkLengths            = expvar.NewMap("requestedChunkLengths")
58
59         messageTypesReceived = expvar.NewMap("messageTypesReceived")
60         messageTypesSent     = expvar.NewMap("messageTypesSent")
61         messageTypesPosted   = expvar.NewMap("messageTypesPosted")
62
63         // Track the effectiveness of Torrent.connPieceInclinationPool.
64         pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused")
65         pieceInclinationsNew    = expvar.NewInt("pieceInclinationsNew")
66         pieceInclinationsPut    = expvar.NewInt("pieceInclinationsPut")
67
68         fillBufferSentCancels  = expvar.NewInt("fillBufferSentCancels")
69         fillBufferSentRequests = expvar.NewInt("fillBufferSentRequests")
70         numFillBuffers         = expvar.NewInt("numFillBuffers")
71 )