mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2025-01-19 04:31:36 +00:00
code style
This commit is contained in:
parent
3a7dba0fda
commit
e9322a32d6
@ -40,10 +40,10 @@ function Client (peerId, port, torrent, opts) {
|
|||||||
self._peerIdHex = self._peerId.toString('hex')
|
self._peerIdHex = self._peerId.toString('hex')
|
||||||
self._peerIdBinary = self._peerId.toString('binary')
|
self._peerIdBinary = self._peerId.toString('binary')
|
||||||
|
|
||||||
self._infoHashBuffer = Buffer.isBuffer(torrent.infoHash)
|
self._infoHash = typeof torrent.infoHash === 'string'
|
||||||
? torrent.infoHash
|
? torrent.infoHash
|
||||||
: new Buffer(torrent.infoHash, 'hex')
|
: torrent.infoHash.toString('hex')
|
||||||
self._infoHash = self._infoHashBuffer.toString('hex')
|
self._infoHashBuffer = new Buffer(self._infoHash, 'hex')
|
||||||
self._infoHashBinary = self._infoHashBuffer.toString('binary')
|
self._infoHashBinary = self._infoHashBuffer.toString('binary')
|
||||||
|
|
||||||
self.torrentLength = torrent.length
|
self.torrentLength = torrent.length
|
||||||
|
@ -68,7 +68,7 @@ HTTPTracker.prototype.scrape = function (opts) {
|
|||||||
? opts.infoHash.map(function (infoHash) {
|
? opts.infoHash.map(function (infoHash) {
|
||||||
return infoHash.toString('binary')
|
return infoHash.toString('binary')
|
||||||
})
|
})
|
||||||
: (opts.infoHash || self.client._infoHashBuffer).toString('binary')
|
: (opts.infoHash && opts.infoHash.toString('binary')) || self.client._infoHashBinary
|
||||||
var params = {
|
var params = {
|
||||||
info_hash: infoHashes
|
info_hash: infoHashes
|
||||||
}
|
}
|
||||||
|
@ -146,7 +146,7 @@ UDPTracker.prototype._request = function (opts) {
|
|||||||
}
|
}
|
||||||
var infoHashes = (Array.isArray(opts.infoHash) && opts.infoHash.length > 0)
|
var infoHashes = (Array.isArray(opts.infoHash) && opts.infoHash.length > 0)
|
||||||
? opts.infoHash.map(function (infoHash) { return infoHash.toString('hex') })
|
? opts.infoHash.map(function (infoHash) { return infoHash.toString('hex') })
|
||||||
: (opts.infoHash || self.client._infoHashBuffer).toString('hex')
|
: (opts.infoHash && opts.infoHash.toString('hex')) || self.client._infoHash
|
||||||
|
|
||||||
for (var i = 0, len = (msg.length - 8) / 12; i < len; i += 1) {
|
for (var i = 0, len = (msg.length - 8) / 12; i < len; i += 1) {
|
||||||
self.client.emit('scrape', {
|
self.client.emit('scrape', {
|
||||||
|
Loading…
Reference in New Issue
Block a user