Comparing version 4.1.1 to 4.1.2
20
index.js
@@ -11,2 +11,3 @@ var raf = require('random-access-file') | ||
// Key-less constant hypercore to bootstrap hypercore-protocol replication. | ||
var defaultEncryptionKey = new Buffer('bee80ff3a4ee5e727dc44197cb9d25bf8f19d50b0f3ad2984cfe5b7d14e75de7', 'hex') | ||
@@ -45,4 +46,2 @@ | ||
this._ready = readyify(function (done) { | ||
// Private key-less constant hypercore to bootstrap hypercore-protocol | ||
// replication. | ||
var encryptionKey = defaultEncryptionKey | ||
@@ -56,6 +55,11 @@ if (self._opts.encryptionKey) { | ||
var feed = hypercore(self._storage('_fake'), encryptionKey) | ||
var storageName = encryptionKey.toString('hex') | ||
var feed = hypercore(self._storage(storageName), encryptionKey) | ||
feed.on('error', function (err) { | ||
self.emit('error', err) | ||
}) | ||
feed.ready(function () { | ||
self._fake = feed | ||
self._root = feed | ||
self._loadFeeds(function (err) { | ||
@@ -99,3 +103,3 @@ if (err) { | ||
var feeds = values(self._feeds).concat(self._fake) | ||
var feeds = values(self._feeds).concat(self._root) | ||
@@ -105,3 +109,3 @@ function next (n) { | ||
self._feeds = [] | ||
self._fake = undefined | ||
self._root = undefined | ||
return done() | ||
@@ -219,3 +223,3 @@ } | ||
Multifeed.prototype.replicate = function (opts) { | ||
if (!this._fake) { | ||
if (!this._root) { | ||
var tmp = through() | ||
@@ -230,3 +234,3 @@ process.nextTick(function () { | ||
var self = this | ||
var mux = multiplexer(self._fake.key, opts) | ||
var mux = multiplexer(self._root.key, opts) | ||
@@ -233,0 +237,0 @@ // Add key exchange listener |
@@ -5,3 +5,3 @@ { | ||
"author": "Stephen Whitmore <sww@eight.net>", | ||
"version": "4.1.1", | ||
"version": "4.1.2", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "url": "git://github.com/noffle/multifeed.git" |
@@ -246,5 +246,5 @@ var test = require('tape') | ||
t.same(multi._opts.encryptionKey, core.key, 'encryption key set') | ||
t.same(multi._fake.key, core.key, 'fake key set') | ||
t.same(multi._root.key, core.key, 'fake key set') | ||
}) | ||
}) | ||
}) |
40309
1065