do not filter out extra keys from 'update' events

This commit is contained in:
Feross Aboukhadijeh 2017-03-10 13:38:04 -08:00
parent 8482c3af0a
commit f65983e466
2 changed files with 14 additions and 17 deletions

View File

@ -190,11 +190,11 @@ HTTPTracker.prototype._onAnnounceResponse = function (data) {
self._trackerId = trackerId
}
self.client.emit('update', {
var response = Object.assign({}, data, {
announce: self.announceUrl,
complete: data.complete,
incomplete: data.incomplete
infoHash: common.binaryToHex(data.info_hash)
})
self.client.emit('update', response)
var addrs
if (Buffer.isBuffer(data.peers)) {
@ -248,15 +248,12 @@ HTTPTracker.prototype._onScrapeResponse = function (data) {
}
keys.forEach(function (infoHash) {
var response = data[infoHash]
// TODO: optionally handle data.flags.min_request_interval
// (separate from announce interval)
self.client.emit('scrape', {
var response = Object.assign(data[infoHash], {
announce: self.announceUrl,
infoHash: common.binaryToHex(infoHash),
complete: response.complete,
incomplete: response.incomplete,
downloaded: response.downloaded
infoHash: common.binaryToHex(infoHash)
})
self.client.emit('scrape', response)
})
}

View File

@ -266,8 +266,11 @@ WebSocketTracker.prototype._onAnnounceResponse = function (data) {
}
if (data.complete != null) {
data.announce = self.announceUrl
self.client.emit('update', data)
var response = Object.assign({}, data, {
announce: self.announceUrl,
infoHash: common.binaryToHex(data.info_hash)
})
self.client.emit('update', response)
}
var peer
@ -323,16 +326,13 @@ WebSocketTracker.prototype._onScrapeResponse = function (data) {
}
keys.forEach(function (infoHash) {
var response = data[infoHash]
// TODO: optionally handle data.flags.min_request_interval
// (separate from announce interval)
self.client.emit('scrape', {
var response = Object.assign(data[infoHash], {
announce: self.announceUrl,
infoHash: common.binaryToHex(infoHash),
complete: response.complete,
incomplete: response.incomplete,
downloaded: response.downloaded
infoHash: common.binaryToHex(infoHash)
})
self.client.emit('scrape', response)
})
}