diff options
author | Feross Aboukhadijeh <feross@feross.org> | 2014-02-26 12:05:01 +0400 |
---|---|---|
committer | Feross Aboukhadijeh <feross@feross.org> | 2014-02-26 12:05:01 +0400 |
commit | 67be9daf627bb7d9d068f3ef16011a7ae4df939f (patch) | |
tree | 31396690e56b0ecc2e036e2667fd17264889d79a /lib/torrent.js | |
parent | 948d2ce7f28093a5f8e91a6fc1572046028fff50 (diff) |
make some torrent methods private
Diffstat (limited to 'lib/torrent.js')
-rw-r--r-- | lib/torrent.js | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/lib/torrent.js b/lib/torrent.js index cb314a2..183157a 100644 --- a/lib/torrent.js +++ b/lib/torrent.js @@ -8,7 +8,7 @@ var parseTorrent = require('parse-torrent') var Swarm = require('bittorrent-swarm') var METADATA_BLOCK_SIZE = 16 * 1024 -var WIRE_TIMEOUT = 10000 +var PIECE_TIMEOUT = 10000 var EXTENDED_MESSAGES = { ut_metadata: 1 @@ -85,8 +85,8 @@ Torrent.prototype._onWire = function (wire) { // dht.add(wire.remoteAddress, port) }) - // Timeout for wire requests to this peer - wire.setTimeout(WIRE_TIMEOUT) + // Timeout for piece requests to this peer + wire.setTimeout(PIECE_TIMEOUT) // Support extended messages: // - ut_metadata (metadata fetching, trackerless torrents) @@ -183,7 +183,7 @@ Torrent.prototype._onUtMetadata = function (wire, buf) { info: self.metadata }) - self.onMetadata() + self._onMetadata() break // ut_metadata reject (peer doesn't have piece we requested) // {'msg_type': 2, 'piece': 0} @@ -193,18 +193,17 @@ Torrent.prototype._onUtMetadata = function (wire, buf) { } } -Torrent.prototype.onMetadata = function () { +Torrent.prototype._onMetadata = function () { var self = this - var parsed try { - parsed = parseTorrent(self.torrentFile) + self.parsedTorrent = parseTorrent(self.torrentFile) } catch (e) { console.error(e) return } - console.log(parsed) - // self.file = new Buffer(parsed) + console.log(self.parsedTorrent) + self.name = self.parsedTorrent.name } // |