Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/webtorrent/webtorrent.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md4
-rw-r--r--index.js2
-rw-r--r--lib/file-stream.js2
-rw-r--r--lib/torrent.js28
-rw-r--r--test/download-dht-magnet.js6
-rw-r--r--test/download-dht-torrent.js7
6 files changed, 25 insertions, 24 deletions
diff --git a/README.md b/README.md
index 94ab6af..c9ad124 100644
--- a/README.md
+++ b/README.md
@@ -254,7 +254,7 @@ If `opts` is specified, then the default options (shown below) will be overridde
{
announce: [], // List of additional trackers to use (added to list in .torrent or magnet uri)
path: String, // Folder where files will be downloaded (default=`/tmp/webtorrent/`)
- storage: Function, // Custom storage engine (must follow `abstract-chunk-store` API)
+ store: Function, // Custom chunk store (must follow `abstract-chunk-store` API)
verify: Boolean // Verify previously stored data before starting (default=false)
}
```
@@ -289,7 +289,7 @@ If `onseed` is specified, it will be called when the client has begun seeding th
#### `client.on('torrent', function (torrent) {})`
-Emitted when a torrent is ready to be used (i.e. metadata is available and storage is
+Emitted when a torrent is ready to be used (i.e. metadata is available and store is
ready). See the torrent section for more info on what methods a `torrent` has.
#### `client.remove(torrentId, [function callback (err) {}])`
diff --git a/index.js b/index.js
index 3a404b2..1f24c4b 100644
--- a/index.js
+++ b/index.js
@@ -193,7 +193,7 @@ WebTorrent.prototype.seed = function (input, opts, onseed) {
debug('seed')
if (!opts) opts = {}
- // When seeding from filesystem path, storage should use existing location
+ // When seeding from filesystem, initialize store from that path (avoids a copy)
if (typeof input === 'string') opts.path = path.dirname(input)
if (!opts.createdBy) opts.createdBy = 'WebTorrent/' + VERSION
diff --git a/lib/file-stream.js b/lib/file-stream.js
index aff81f1..b69c551 100644
--- a/lib/file-stream.js
+++ b/lib/file-stream.js
@@ -54,7 +54,7 @@ FileStream.prototype._notify = function () {
self._notifying = true
var p = self._piece
- self._torrent.storage.get(p, function (err, buffer) {
+ self._torrent.store.get(p, function (err, buffer) {
self._notifying = false
if (self.destroyed) return
if (err) return self.destroy(err)
diff --git a/lib/torrent.js b/lib/torrent.js
index 4a59bab..c1d594c 100644
--- a/lib/torrent.js
+++ b/lib/torrent.js
@@ -60,7 +60,7 @@ function Torrent (torrentId, opts) {
self.urlList = opts.urlList
self._path = opts.path
- self._storage = opts.storage || FSChunkStore
+ self._store = opts.store || FSChunkStore
self.strategy = opts.strategy || 'sequential'
@@ -74,7 +74,7 @@ function Torrent (torrentId, opts) {
self.ready = false
self.destroyed = false
self.metadata = null
- self.storage = null
+ self.store = null
self.numBlockedPeers = 0
self.files = null
self.done = false
@@ -306,8 +306,8 @@ Torrent.prototype._onMetadata = function (metadata) {
self.rarityMap = new RarityMap(self.swarm, self.pieces.length)
- self.storage = new ImmediateChunkStore(
- new self._storage(self.pieceLength, {
+ self.store = new ImmediateChunkStore(
+ new self._store(self.pieceLength, {
files: self.files.map(function (file) {
return {
path: path.join(self._path, file.path),
@@ -376,7 +376,7 @@ Torrent.prototype._onMetadata = function (metadata) {
// }), self._onStorage.bind(self))
// })
process.nextTick(function () {
- self._onStorage()
+ self._onStore()
})
process.nextTick(function () {
@@ -385,12 +385,12 @@ Torrent.prototype._onMetadata = function (metadata) {
}
/**
- * Called when the metadata, swarm, and underlying storage are all fully initialized.
+ * Called when the metadata, swarm, and underlying chunk store is initialized.
*/
-Torrent.prototype._onStorage = function () {
+Torrent.prototype._onStore = function () {
var self = this
if (self.destroyed) return
- debug('on storage')
+ debug('on store')
// start off selecting the entire torrent with low priority
self.select(0, self.pieces.length - 1, false)
@@ -428,7 +428,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.storage) tasks.push(function (cb) { self.storage.close(cb) })
+ if (self.store) tasks.push(function (cb) { self.store.close(cb) })
parallel(tasks, cb)
}
@@ -680,7 +680,7 @@ Torrent.prototype._onWireWithMetadata = function (wire) {
return wire.destroy()
}
if (self.pieces[index]) return
- self.storage.get(index, { offset: offset, length: length }, cb)
+ self.store.get(index, { offset: offset, length: length }, cb)
})
wire.bitfield(self.bitfield) // always send bitfield (required)
@@ -707,7 +707,7 @@ Torrent.prototype._updateSelections = function () {
}
/**
- * Garbage collect selections with respect to the storage's current state.
+ * Garbage collect selections with respect to the store's current state.
*/
Torrent.prototype._gcSelections = function () {
var self = this
@@ -1049,7 +1049,7 @@ Torrent.prototype._request = function (wire, index, hotswap) {
var maxOutstandingRequests = getPipelineLength(wire, PIPELINE_MAX_DURATION)
if (numRequests >= maxOutstandingRequests) return false
- // var endGame = (wire.requests.length === 0 && self.storage.numMissing < 30)
+ // var endGame = (wire.requests.length === 0 && self.store.numMissing < 30)
var piece = self.pieces[index]
var reservation = piece.reserve()
@@ -1107,7 +1107,7 @@ Torrent.prototype._request = function (wire, index, hotswap) {
self._reservations[index] = null
self.bitfield.set(index, true)
- self.storage.put(index, buf)
+ self.store.put(index, buf)
self.swarm.wires.forEach(function (wire) {
wire.have(index)
@@ -1151,7 +1151,7 @@ Torrent.prototype._request = function (wire, index, hotswap) {
Torrent.prototype.load = function (streams, cb) {
var self = this
if (!cb) cb = noop
- loadChunkStore(streams, this.storage, Piece.BLOCK_LENGTH, function (err) {
+ loadChunkStore(streams, this.store, Piece.BLOCK_LENGTH, function (err) {
if (err) return cb(err)
self.pieces.forEach(function (piece, index) {
self.pieces[index] = null
diff --git a/test/download-dht-magnet.js b/test/download-dht-magnet.js
index 93e9534..b1c6a7a 100644
--- a/test/download-dht-magnet.js
+++ b/test/download-dht-magnet.js
@@ -38,9 +38,9 @@ test('Download using DHT (via magnet uri)', function (t) {
client1.on('warning', function (err) { t.fail(err) })
var announced = false
- var wroteStorage = false
+ var loaded = false
function maybeDone () {
- if (announced && wroteStorage) cb(null, client1)
+ if (announced && loaded) cb(null, client1)
}
client1.add(leavesParsed, function (torrent) {
@@ -57,7 +57,7 @@ test('Download using DHT (via magnet uri)', function (t) {
torrent.load(fs.createReadStream(leavesPath), function (err) {
t.error(err)
- wroteStorage = true
+ loaded = true
maybeDone()
})
})
diff --git a/test/download-dht-torrent.js b/test/download-dht-torrent.js
index 50e2013..bc51a71 100644
--- a/test/download-dht-torrent.js
+++ b/test/download-dht-torrent.js
@@ -38,9 +38,10 @@ test('Download using DHT (via .torrent file)', function (t) {
client1.add(leavesParsed)
- var announced, wroteStorage
+ var announced = false
+ var loaded = false
function maybeDone (err) {
- if ((announced && wroteStorage) || err) cb(err, client1)
+ if ((announced && loaded) || err) cb(err, client1)
}
client1.on('torrent', function (torrent) {
@@ -56,7 +57,7 @@ test('Download using DHT (via .torrent file)', function (t) {
})
torrent.load(fs.createReadStream(leavesPath), function (err) {
- wroteStorage = true
+ loaded = true
maybeDone(err)
})
})