Comparing version 5.2.1 to 5.2.2
12
mux.js
@@ -212,3 +212,3 @@ var Protocol = require('hypercore-protocol') | ||
// Start replicating as promised. | ||
this._replicateFeeds(filtered) | ||
this._replicateFeeds(filtered, false) | ||
} | ||
@@ -223,3 +223,3 @@ | ||
// Start replicating as requested. | ||
this._replicateFeeds(filtered, function () { | ||
this._replicateFeeds(filtered, true, function () { | ||
self.stream.emit('remote-feeds') | ||
@@ -231,3 +231,3 @@ }) | ||
// the main stream. | ||
Multiplexer.prototype._replicateFeeds = function (keys, cb) { | ||
Multiplexer.prototype._replicateFeeds = function (keys, terminateIfNoFeeds, cb) { | ||
if (!cb) cb = noop | ||
@@ -295,6 +295,8 @@ | ||
// Bail on replication entirely if there were no feeds to add, and none are pending or active. | ||
if (feeds.length === 0 && Object.keys(self._activeFeedStreams).length === 0) { | ||
debug('[REPLICATION] terminating mux: no feeds to sync') | ||
if (feeds.length === 0 && Object.keys(self._activeFeedStreams).length === 0 && terminateIfNoFeeds) { | ||
debug(self._id, '[REPLICATION] terminating mux: no feeds to sync') | ||
self._feed.close() | ||
process.nextTick(cb) | ||
} else if (feeds.length === 0) { | ||
process.nextTick(cb) | ||
} | ||
@@ -301,0 +303,0 @@ } |
@@ -5,3 +5,3 @@ { | ||
"author": "Stephen Whitmore <sww@eight.net>", | ||
"version": "5.2.1", | ||
"version": "5.2.2", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "url": "git://github.com/noffle/multifeed.git" |
@@ -71,4 +71,8 @@ # multifeed | ||
Pass in a [random-access-storage](https://github.com/random-access-storage/random-access-storage) backend, and options. Included `opts` are passed into new hypercores created, and are the same as [hypercore](https://github.com/mafintosh/hypercore#var-feed--hypercorestorage-key-options)'s. | ||
Create a multifeed. | ||
`storage` is a [random-access-storage](https://github.com/random-access-storage) function, or a string. If a string is given, [random-access-file](https://github.com/random-access-storage/random-access-storage) is used with that string as the filename. | ||
Included `opts` are passed into new hypercores created, and are the same as [hypercore](https://github.com/mafintosh/hypercore#var-feed--hypercorestorage-key-options)'s. | ||
Valid `opts` include: | ||
@@ -75,0 +79,0 @@ - `opts.encryptionKey` (string): optional encryption key to use during replication. If not provided, a default insecure key will be used. |
28579
645
170