Comparing version 1.3.8 to 1.3.9
28
index.js
@@ -144,3 +144,6 @@ var raf = require('random-access-file') | ||
var pending = 0 | ||
keys.forEach(function (key) { | ||
var filtered = keys.filter(function (key) { | ||
return Buffer.isBuffer(key) && key.length === 32 | ||
}) | ||
filtered.forEach(function (key) { | ||
var feeds = Object.values(self._feeds).filter(function (feed) { | ||
@@ -151,13 +154,15 @@ return feed.key.equals(key) | ||
pending++ | ||
var numFeeds = Object.keys(self._feeds).length | ||
var storage = self._storage(''+numFeeds) | ||
var feed | ||
try { | ||
var numFeeds = Object.keys(self._feeds).length | ||
var storage = self._storage(''+numFeeds) | ||
var feed = self._hypercore(storage, key, self._opts) | ||
self._addFeed(feed, String(numFeeds)) | ||
feed.ready(function () { | ||
if (!--pending) cb() | ||
}) | ||
feed = self._hypercore(storage, key, self._opts) | ||
} catch (e) { | ||
if (!--pending) cb() | ||
return | ||
} | ||
self._addFeed(feed, String(numFeeds)) | ||
feed.ready(function () { | ||
if (!--pending) cb() | ||
}) | ||
} | ||
@@ -186,2 +191,6 @@ }) | ||
var res = deserializeFeedBuf(buf) | ||
if (!res) { | ||
// probably replicating with a non-multifeed peer: abort | ||
return next(new Error('replicating with non-multifeed peer')) | ||
} | ||
var keys = res[0] | ||
@@ -255,2 +264,5 @@ var size = res[1] | ||
function deserializeFeedBuf (buf) { | ||
// bad msg | ||
if ((buf.length - 2) % 32 !== 0) return null | ||
var numFeeds = buf.readUInt16LE(0) | ||
@@ -257,0 +269,0 @@ var res = [] |
@@ -5,3 +5,3 @@ { | ||
"author": "Stephen Whitmore <sww@eight.net>", | ||
"version": "1.3.8", | ||
"version": "1.3.9", | ||
"repository": { | ||
@@ -8,0 +8,0 @@ "url": "git://github.com/noffle/multifeed.git" |
@@ -101,2 +101,4 @@ # multifeed | ||
**Note**: this stream is *not* an encrypted channel. | ||
### multi.on('feed', function (feed, name) { ... }) | ||
@@ -103,0 +105,0 @@ |
20899
549
138
91