Skip to content

Commit e9322a3

Browse files
committed
code style
1 parent 3a7dba0 commit e9322a3

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

client.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ function Client (peerId, port, torrent, opts) {
4040
self._peerIdHex = self._peerId.toString('hex')
4141
self._peerIdBinary = self._peerId.toString('binary')
4242

43-
self._infoHashBuffer = Buffer.isBuffer(torrent.infoHash)
43+
self._infoHash = typeof torrent.infoHash === 'string'
4444
? torrent.infoHash
45-
: new Buffer(torrent.infoHash, 'hex')
46-
self._infoHash = self._infoHashBuffer.toString('hex')
45+
: torrent.infoHash.toString('hex')
46+
self._infoHashBuffer = new Buffer(self._infoHash, 'hex')
4747
self._infoHashBinary = self._infoHashBuffer.toString('binary')
4848

4949
self.torrentLength = torrent.length

lib/client/http-tracker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ HTTPTracker.prototype.scrape = function (opts) {
6868
? opts.infoHash.map(function (infoHash) {
6969
return infoHash.toString('binary')
7070
})
71-
: (opts.infoHash || self.client._infoHashBuffer).toString('binary')
71+
: (opts.infoHash && opts.infoHash.toString('binary')) || self.client._infoHashBinary
7272
var params = {
7373
info_hash: infoHashes
7474
}

lib/client/udp-tracker.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ UDPTracker.prototype._request = function (opts) {
146146
}
147147
var infoHashes = (Array.isArray(opts.infoHash) && opts.infoHash.length > 0)
148148
? opts.infoHash.map(function (infoHash) { return infoHash.toString('hex') })
149-
: (opts.infoHash || self.client._infoHashBuffer).toString('hex')
149+
: (opts.infoHash && opts.infoHash.toString('hex')) || self.client._infoHash
150150

151151
for (var i = 0, len = (msg.length - 8) / 12; i < len; i += 1) {
152152
self.client.emit('scrape', {

0 commit comments

Comments
 (0)