4 pp "github.com/anacrolix/torrent/peer_protocol"
10 pieceHash = crypto.SHA1
11 maxRequests = 250 // Maximum pending requests we allow peers to send us.
12 defaultChunkSize = 0x4000 // 16KiB
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
20 func defaultPeerExtensionBytes() PeerExtensionBits {
21 return pp.NewPeerExtensionBytes(pp.ExtensionBitDHT, pp.ExtensionBitExtended, pp.ExtensionBitFast)
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.
27 torrent = expvar.NewMap("torrent")
29 peersAddedBySource = expvar.NewMap("peersAddedBySource")
31 pieceHashedCorrect = expvar.NewInt("pieceHashedCorrect")
32 pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
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")
45 messageTypesReceived = expvar.NewMap("messageTypesReceived")
47 // Track the effectiveness of Torrent.connPieceInclinationPool.
48 pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused")
49 pieceInclinationsNew = expvar.NewInt("pieceInclinationsNew")
50 pieceInclinationsPut = expvar.NewInt("pieceInclinationsPut")