Skip to content

Commit

Permalink
Merge pull request #7 from astro/choke-optimization
Browse files Browse the repository at this point in the history
choke: discard peerRequests optimization
  • Loading branch information
feross committed Jan 23, 2015
2 parents c41d091 + 007ff6e commit 711a346
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ function Wire () {

this.peerExtensions = {}

// outgoing
this.requests = []
// incoming
this.peerRequests = []

/** @type {Object} number -> string, ex: 1 -> 'ut_metadata' */
Expand Down Expand Up @@ -187,7 +189,7 @@ Wire.prototype.handshake = function (infoHash, peerId, extensions) {
Wire.prototype.choke = function () {
if (this.amChoking) return
this.amChoking = true
while (this.peerRequests.length) this.peerRequests.pop()
this.peerRequests.splice(0, this.peerRequests.length)
this._push(MESSAGE_CHOKE)
}

Expand Down

0 comments on commit 711a346

Please sign in to comment.