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