Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download larger chunks from webseeds. #545

Merged
merged 2 commits into from Mar 1, 2016
Merged
Changes from 1 commit
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

Next

Updated torrent.js

  • Loading branch information
DiegoRBaquero committed Dec 28, 2015
commit 30f00a52cfb7da46dfd27560129777b0f4d98ea2
@@ -1055,17 +1055,19 @@ Torrent.prototype._request = function (wire, index, hotswap) {
var self = this
var numRequests = wire.requests.length

var webPeer = wire.remotePort === 80 || wire.remotePort === 443

This comment has been minimized.

Copy link
@feross

feross Mar 1, 2016

Member

Normal peers can listen on port 80 or 443. There are no rules about what ports a client can use, so this might match a normal peer. Not a huge deal right now, but it's better to be explicit since we might add other custom code for web seeds in the future and it could cause trouble.

This comment has been minimized.

Copy link
@feross

feross Mar 1, 2016

Member

I fixed this up!


if (self.bitfield.get(index)) return false

var maxOutstandingRequests = getPipelineLength(wire, PIPELINE_MAX_DURATION)
if (numRequests >= maxOutstandingRequests) return false
// var endGame = (wire.requests.length === 0 && self.store.numMissing < 30)

var piece = self.pieces[index]
var reservation = piece.reserve()
var reservation = webPeer ? piece.reserveRemaining() : piece.reserve()

if (reservation === -1 && hotswap && self._hotswap(wire, index)) {
reservation = piece.reserve()
reservation = webPeer ? piece.reserveRemaining() : piece.reserve()
}
if (reservation === -1) return false

@@ -1076,7 +1078,7 @@ Torrent.prototype._request = function (wire, index, hotswap) {
r[i] = wire

var chunkOffset = piece.chunkOffset(reservation)
var chunkLength = piece.chunkLength(reservation)
var chunkLength = webPeer ? piece.chunkLengthRemaining(reservation) : piece.chunkLength(reservation)

wire.request(index, chunkOffset, chunkLength, function onChunk (err, chunk) {
// TODO: what is this for?
@@ -1092,7 +1094,7 @@ Torrent.prototype._request = function (wire, index, hotswap) {
index, chunkOffset, chunkLength, wire.remoteAddress + ':' + wire.remotePort,
err.message
)
piece.cancel(reservation)
webPeer ? piece.cancelRemaining(reservation) : piece.cancel(reservation)
onUpdateTick()
return
}
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.