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

Provide a way to give extra data to the tracker on announce #595

Merged
merged 4 commits into from Feb 29, 2016
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -93,6 +93,7 @@ function Torrent (torrentId, client, opts) {
this.pieces = []
this._selections = []
this._critical = []
this._getExtraAnnounceOpts = opts.getExtraAnnounceOpts

This comment has been minimized.

Copy link
@feross

feross Feb 8, 2016

Member

I'd rather name this consistently with the bittorrent-tracker option. getAnnounceOpts


// for cleanup
this._servers = []
@@ -298,7 +299,15 @@ Torrent.prototype._onSwarmListening = function () {
peerId: self.client.peerId,
port: self.client.torrentPort,
rtcConfig: self.client._rtcConfig,
wrtc: self.client._wrtc
wrtc: self.client._wrtc,
getAnnounceOpts: function () {
return {
uploaded: self.uploaded,
downloaded: self.downloaded,
left: self.length - self.downloaded,
extraAnnounceOpts: self._getExtraAnnounceOpts && self._getExtraAnnounceOpts()

This comment has been minimized.

Copy link
@feross

feross Feb 8, 2016

Member

Instead of passing the user's custom announce opts separately in this extraAnnounceOpts property, can we merge their properties with the uploaded, downloaded, and left params?

Thinking something like this:

getAnnounceOpts: function () {
  return extend({
    uploaded: self.uploaded,
    downloaded: self.downloaded,
    left: self.length - self.downloaded
  }, self._getExtraAnnounceOpts && self._getExtraAnnounceOpts())
})

This ordering will mean that the user's values for uploaded, downloaded, and left (if they exist) will take precedence.

}
}
})
self.discovery.on('error', self._onError.bind(self))
self.discovery.on('peer', self.addPeer.bind(self))
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.