]> Sergey Matveev's repositories - btrtrc.git/blob - global.go
Generate default peerExtensionBytes using helpers
[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)
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         peersAddedBySource = expvar.NewMap("peersAddedBySource")
31
32         uploadChunksPosted = expvar.NewInt("uploadChunksPosted")
33         unexpectedCancels  = expvar.NewInt("unexpectedCancels")
34
35         pieceHashedCorrect    = expvar.NewInt("pieceHashedCorrect")
36         pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
37
38         unsuccessfulDials = expvar.NewInt("dialSuccessful")
39         successfulDials   = expvar.NewInt("dialUnsuccessful")
40
41         acceptUTP    = expvar.NewInt("acceptUTP")
42         acceptTCP    = expvar.NewInt("acceptTCP")
43         acceptReject = expvar.NewInt("acceptReject")
44
45         peerExtensions                    = expvar.NewMap("peerExtensions")
46         completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
47         // Count of connections to peer with same client ID.
48         connsToSelf = expvar.NewInt("connsToSelf")
49         // Number of completed connections to a client we're already connected with.
50         duplicateClientConns       = expvar.NewInt("duplicateClientConns")
51         receivedKeepalives         = expvar.NewInt("receivedKeepalives")
52         supportedExtensionMessages = expvar.NewMap("supportedExtensionMessages")
53         postedKeepalives           = expvar.NewInt("postedKeepalives")
54         // Requests received for pieces we don't have.
55         requestsReceivedForMissingPieces = expvar.NewInt("requestsReceivedForMissingPieces")
56         requestedChunkLengths            = expvar.NewMap("requestedChunkLengths")
57
58         messageTypesReceived = expvar.NewMap("messageTypesReceived")
59         messageTypesSent     = expvar.NewMap("messageTypesSent")
60         messageTypesPosted   = expvar.NewMap("messageTypesPosted")
61
62         // Track the effectiveness of Torrent.connPieceInclinationPool.
63         pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused")
64         pieceInclinationsNew    = expvar.NewInt("pieceInclinationsNew")
65         pieceInclinationsPut    = expvar.NewInt("pieceInclinationsPut")
66
67         fillBufferSentCancels  = expvar.NewInt("fillBufferSentCancels")
68         fillBufferSentRequests = expvar.NewInt("fillBufferSentRequests")
69         numFillBuffers         = expvar.NewInt("numFillBuffers")
70 )