]> Sergey Matveev's repositories - btrtrc.git/blob - global.go
sortimports
[btrtrc.git] / global.go
1 package torrent
2
3 import (
4         "crypto"
5         "expvar"
6
7         pp "github.com/anacrolix/torrent/peer_protocol"
8 )
9
10 const (
11         pieceHash        = crypto.SHA1
12         maxRequests      = 250    // Maximum pending requests we allow peers to send us.
13         defaultChunkSize = 0x4000 // 16KiB
14
15         // These are our extended message IDs. Peers will use these values to
16         // select which extension a message is intended for.
17         metadataExtendedId = iota + 1 // 0 is reserved for deleting keys
18         pexExtendedId
19 )
20
21 func defaultPeerExtensionBytes() PeerExtensionBits {
22         return pp.NewPeerExtensionBytes(pp.ExtensionBitDHT, pp.ExtensionBitExtended, pp.ExtensionBitFast)
23 }
24
25 // I could move a lot of these counters to their own file, but I suspect they
26 // may be attached to a Client someday.
27 var (
28         torrent = expvar.NewMap("torrent")
29
30         peersAddedBySource = expvar.NewMap("peersAddedBySource")
31
32         pieceHashedCorrect    = expvar.NewInt("pieceHashedCorrect")
33         pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
34
35         peerExtensions                    = expvar.NewMap("peerExtensions")
36         completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
37         // Count of connections to peer with same client ID.
38         connsToSelf                = expvar.NewInt("connsToSelf")
39         receivedKeepalives         = expvar.NewInt("receivedKeepalives")
40         supportedExtensionMessages = expvar.NewMap("supportedExtensionMessages")
41         postedKeepalives           = expvar.NewInt("postedKeepalives")
42         // Requests received for pieces we don't have.
43         requestsReceivedForMissingPieces = expvar.NewInt("requestsReceivedForMissingPieces")
44         requestedChunkLengths            = expvar.NewMap("requestedChunkLengths")
45
46         messageTypesReceived = expvar.NewMap("messageTypesReceived")
47
48         // Track the effectiveness of Torrent.connPieceInclinationPool.
49         pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused")
50         pieceInclinationsNew    = expvar.NewInt("pieceInclinationsNew")
51         pieceInclinationsPut    = expvar.NewInt("pieceInclinationsPut")
52 )