7 pp "github.com/anacrolix/torrent/peer_protocol"
11 pieceHash = crypto.SHA1
12 defaultChunkSize = 0x4000 // 16KiB
14 // Arbitrary maximum of "metadata_size" (see https://www.bittorrent.org/beps/bep_0009.html)
15 // This value is 2x what libtorrent-rasterbar uses, which should be plenty
16 maxMetadataSize uint32 = 8 * 1024 * 1024
19 // These are our extended message IDs. Peers will use these values to
20 // select which extension a message is intended for.
22 metadataExtendedId = iota + 1 // 0 is reserved for deleting keys
26 func defaultPeerExtensionBytes() PeerExtensionBits {
27 return pp.NewPeerExtensionBytes(pp.ExtensionBitDHT, pp.ExtensionBitExtended, pp.ExtensionBitFast)
31 torrent.Set("peers supporting extension", &peersSupportingExtension)
32 torrent.Set("chunks received", &chunksReceived)
35 // I could move a lot of these counters to their own file, but I suspect they
36 // may be attached to a Client someday.
38 torrent = expvar.NewMap("torrent")
39 peersSupportingExtension expvar.Map
40 chunksReceived expvar.Map
42 pieceHashedCorrect = expvar.NewInt("pieceHashedCorrect")
43 pieceHashedNotCorrect = expvar.NewInt("pieceHashedNotCorrect")
45 completedHandshakeConnectionFlags = expvar.NewMap("completedHandshakeConnectionFlags")
46 // Count of connections to peer with same client ID.
47 connsToSelf = expvar.NewInt("connsToSelf")
48 receivedKeepalives = expvar.NewInt("receivedKeepalives")
49 // Requests received for pieces we don't have.
50 requestsReceivedForMissingPieces = expvar.NewInt("requestsReceivedForMissingPieces")
51 requestedChunkLengths = expvar.NewMap("requestedChunkLengths")
53 messageTypesReceived = expvar.NewMap("messageTypesReceived")
55 // Track the effectiveness of Torrent.connPieceInclinationPool.
56 pieceInclinationsReused = expvar.NewInt("pieceInclinationsReused")
57 pieceInclinationsNew = expvar.NewInt("pieceInclinationsNew")
58 pieceInclinationsPut = expvar.NewInt("pieceInclinationsPut")
60 concurrentChunkWrites = expvar.NewInt("torrentConcurrentChunkWrites")