mirror of
https://github.com/webtorrent/bittorrent-tracker.git
synced 2024-12-14 03:16:24 +00:00
use delete obj[key]
instead of obj[key] = null
This commit is contained in:
parent
32c2e985fd
commit
0585d8b18a
@ -70,7 +70,7 @@ WebSocketTracker.prototype.destroy = function (onclose) {
|
||||
self.destroyed = true
|
||||
clearInterval(self.interval)
|
||||
|
||||
socketPool[self.announceUrl] = null
|
||||
delete socketPool[self.announceUrl]
|
||||
|
||||
self.socket.removeListener('connect', self._onSocketConnectBound)
|
||||
self.socket.removeListener('data', self._onSocketDataBound)
|
||||
@ -208,7 +208,7 @@ WebSocketTracker.prototype._onSocketData = function (data) {
|
||||
|
||||
clearTimeout(peer.trackerTimeout)
|
||||
peer.trackerTimeout = null
|
||||
self.peers[offerId] = null
|
||||
delete self.peers[offerId]
|
||||
} else {
|
||||
debug('got unexpected answer: ' + JSON.stringify(data.answer))
|
||||
}
|
||||
@ -281,7 +281,7 @@ WebSocketTracker.prototype._generateOffers = function (numwant, cb) {
|
||||
peer.trackerTimeout = setTimeout(function () {
|
||||
debug('tracker timeout: destroying peer')
|
||||
peer.trackerTimeout = null
|
||||
self.peers[offerId] = null
|
||||
delete self.peers[offerId]
|
||||
peer.destroy()
|
||||
}, OFFER_TIMEOUT)
|
||||
}
|
||||
|
@ -103,7 +103,6 @@ Swarm.prototype._getPeers = function (numwant, ownPeerId, isWebRTC) {
|
||||
var peerId
|
||||
while ((peerId = ite()) && peers.length < numwant) {
|
||||
var peer = this.peers[peerId]
|
||||
if (!peer) continue
|
||||
if (isWebRTC && peer.peerId === ownPeerId) continue // don't send peer to itself
|
||||
if ((isWebRTC && peer.ip) || (!isWebRTC && peer.socket)) continue // send proper peer type
|
||||
peers.push(peer)
|
||||
|
Loading…
Reference in New Issue
Block a user