Skip to content

Commit 582ac99

Browse files
committed
webtorrent perf: create 5 offers at a time
1 parent a26a210 commit 582ac99

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

lib/client/websocket-tracker.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,8 @@ WebSocketTracker.prototype.announce = function (opts) {
4242
return self.socket.once('connect', self.announce.bind(self, opts))
4343
}
4444

45-
// TODO: Limit number of offers (temporarily)
46-
// TODO: remove this when we cleanup old RTCPeerConnections cleanly
47-
var numwant = Math.min(opts.numwant, 10)
45+
// Limit the number of offers that are generated, since it can be slow
46+
var numwant = Math.min(opts.numwant, 5)
4847

4948
self._generateOffers(numwant, function (offers) {
5049
var params = {
@@ -177,6 +176,7 @@ WebSocketTracker.prototype._onSocketData = function (data) {
177176

178177
var peer
179178
if (data.offer && data.peer_id) {
179+
debug('creating peer (from remote offer)')
180180
peer = new Peer({
181181
trickle: false,
182182
config: self.client._rtcConfig,
@@ -260,6 +260,7 @@ WebSocketTracker.prototype._generateOffers = function (numwant, cb) {
260260

261261
function generateOffer () {
262262
var offerId = hat(160)
263+
debug('creating peer (from _generateOffers)')
263264
var peer = self.peers[offerId] = new Peer({
264265
initiator: true,
265266
trickle: false,

0 commit comments

Comments
 (0)