7 pp "github.com/anacrolix/torrent/peer_protocol"
11 pieceHash = crypto.SHA1
12 maxRequests = 250 // Maximum pending requests we allow peers to send us.
13 defaultChunkSize = 0x4000 // 16KiB
16 // These are our extended message IDs. Peers will use these values to
17 // select which extension a message is intended for.
19 metadataExtendedId = iota + 1 // 0 is reserved for deleting keys
23 func defaultPeerExtensionBytes() PeerExtensionBits {
24 return pp.NewPeerExtensionBytes(pp.ExtensionBitDHT, pp.ExtensionBitExtended, pp.ExtensionBitFast)
27 // I could move a lot of these counters to their own file, but I suspect they
28 // may be attached to a Client someday.
30 torrent = expvar.NewMap("torrent")
32 peersAddedBySource = expvar.NewMap("peersAddedBySource")
34 pieceHashedCorrect = expvar.NewInt("pieceHashedCorrect")
35 pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
37 peerExtensions = expvar.NewMap("peerExtensions")
38 completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
39 // Count of connections to peer with same client ID.
40 connsToSelf = expvar.NewInt("connsToSelf")
41 receivedKeepalives = expvar.NewInt("receivedKeepalives")
42 postedKeepalives = expvar.NewInt("postedKeepalives")
43 // Requests received for pieces we don't have.
44 requestsReceivedForMissingPieces = expvar.NewInt("requestsReceivedForMissingPieces")
45 requestedChunkLengths = expvar.NewMap("requestedChunkLengths")
47 messageTypesReceived = expvar.NewMap("messageTypesReceived")
49 // Track the effectiveness of Torrent.connPieceInclinationPool.
50 pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused")
51 pieceInclinationsNew = expvar.NewInt("pieceInclinationsNew")
52 pieceInclinationsPut = expvar.NewInt("pieceInclinationsPut")