Comparing version 4.1.8 to 4.1.9
@@ -19,2 +19,3 @@ var raf = require('random-access-file') | ||
this._id = (opts||{})._id || Math.floor(Math.random() * 1000).toString(16) // for debugging | ||
debug(this._id, 'multifeed @ ' + require(path.join(__dirname,'package.json')).version) | ||
this._feeds = {} | ||
@@ -240,3 +241,3 @@ this._feedKeyToFeed = {} | ||
var self = this | ||
var mux = multiplexer(self._root.key, opts) | ||
var mux = multiplexer(self._root.key, Object.assign({}, opts, {_id:this._id})) | ||
@@ -243,0 +244,0 @@ // Add key exchange listener |
21
mux.js
@@ -81,3 +81,3 @@ var protocol = require('hypercore-protocol') | ||
try { | ||
debug(self._id + 'Extension:', type, message.toString('utf8')) | ||
debug(self._id, 'Extension:', type, message.toString('utf8')) | ||
var data = JSON.parse(message.toString('utf8')) | ||
@@ -172,3 +172,3 @@ switch(type) { | ||
// Tell remote which keys we will replicate | ||
debug('[REPLICATION] Sending REPLICATE_FEEDS') | ||
debug(this._id, '[REPLICATION] Sending REPLICATE_FEEDS') | ||
this._feed.extension(REPLICATE_FEEDS, Buffer.from(JSON.stringify(filtered))) | ||
@@ -195,4 +195,10 @@ | ||
keys = uniq(keys) | ||
debug(this._id + '[REPLICATION] _replicateFeeds', keys.length, keys) | ||
debug(this._id, '[REPLICATION] _replicateFeeds', keys.length, keys) | ||
// Increment expected feeds to keep the stream alive until all pending cores | ||
// are added. Otherwise a non-live replication might terminate because it | ||
// thinks all feeds have been synced, even though new ones are still in the | ||
// process of being set up for sync. | ||
this.stream.expectedFeeds++ | ||
this.emit('replicate', keys, startFeedReplication) | ||
@@ -203,2 +209,5 @@ | ||
function startFeedReplication(feeds){ | ||
// Decrement back down the expected feeds. | ||
self.stream.expectedFeeds-- | ||
if (!Array.isArray(feeds)) feeds = [feeds] | ||
@@ -215,3 +224,3 @@ self.stream.expectedFeeds += feeds.length | ||
if (typeof self._activeFeedStreams[hexKey] !== 'undefined') { | ||
debug(self._id + '[REPLICATION] warning! Prevented duplicate replication of: ', hexKey) | ||
debug(self._id, '[REPLICATION] warning! Prevented duplicate replication of: ', hexKey) | ||
// decrease the expectedFeeds that was unconditionally increased | ||
@@ -222,3 +231,3 @@ self.stream.expectedFeeds-- | ||
debug(self._id + '[REPLICATION] replicating feed:', hexKey) | ||
debug(self._id, '[REPLICATION] replicating feed:', hexKey) | ||
var fStream = feed.replicate(Object.assign({}, { | ||
@@ -239,3 +248,3 @@ live: self._opts.live, | ||
delete self._activeFeedStreams[hexKey] | ||
debug(self._id + "[REPLICATION] feedStream closed:", hexKey.substr(0,8)) | ||
debug(self._id, "[REPLICATION] feedStream closed:", hexKey.substr(0,8)) | ||
} | ||
@@ -242,0 +251,0 @@ fStream.once('end', cleanup) |
@@ -5,3 +5,3 @@ { | ||
"author": "Stephen Whitmore <sww@eight.net>", | ||
"version": "4.1.8", | ||
"version": "4.1.9", | ||
"repository": { | ||
@@ -30,3 +30,4 @@ "url": "git://github.com/noffle/multifeed.git" | ||
"pumpify": "^1.5.1", | ||
"random-access-memory": "^2.4.0", | ||
"random-access-latency": "^1.0.0", | ||
"random-access-memory": "^3.1.1", | ||
"rimraf": "^2.6.3", | ||
@@ -33,0 +34,0 @@ "standard": "~10.0.0", |
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
25244
9
5
592
2