diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2016-04-01 08:01:55 +0300 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2016-04-01 08:01:55 +0300 |
commit | 2e898d71902bb1938439a29f8b53a2eb24f2c78a (patch) | |
tree | 957302ac186a539a2add143f6cfb023ab70f4211 | |
parent | 917817552bff23b092a740467cad671743fad78a (diff) |
Changes for torrent-discovery@8
-rw-r--r-- | lib/torrent.js | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/lib/torrent.js b/lib/torrent.js index d4a8e2c..527ba55 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -297,10 +297,11 @@ Torrent.prototype._onSwarmListening = function () { // begin discovering peers via DHT and trackers self.discovery = new Discovery({ + infoHash: self.infoHash, announce: self.announce, + peerId: self.client.peerId, dht: !self.private && self.client.dht, tracker: self.client.tracker && trackerOpts, - peerId: self.client.peerId, port: self.client.torrentPort }) self.discovery.on('error', function (err) { @@ -323,9 +324,9 @@ Torrent.prototype._onSwarmListening = function () { self.emit('warning', err) }) - // if full metadata was included in initial torrent id, use it + // if full metadata was included in initial torrent id, use it immediately. Otherwise, + // wait for torrent-discovery to find peers and ut_metadata to get the metadata. if (self.info) self._onMetadata(self) - else self.discovery.setTorrent(self.infoHash) self.emit('listening', self.client.torrentPort) } @@ -353,9 +354,6 @@ Torrent.prototype._onMetadata = function (metadata) { self._processParsedTorrent(parsedTorrent) self.metadata = self.torrentFile - // pass full torrent metadata to discovery module - self.discovery.setTorrent(self) - // add web seed urls (BEP19) self.urlList.forEach(function (url) { self.addWebSeed(url) @@ -477,7 +475,7 @@ Torrent.prototype.destroy = function (cb) { }) if (self.swarm) tasks.push(function (cb) { self.swarm.destroy(cb) }) - if (self.discovery) tasks.push(function (cb) { self.discovery.stop(cb) }) + if (self.discovery) tasks.push(function (cb) { self.discovery.destroy(cb) }) if (self.store) tasks.push(function (cb) { self.store.close(cb) }) parallel(tasks, cb) |