epidemic-broadcast-trees
Advanced tools
Comparing version 8.0.6 to 8.0.7
34
index.js
@@ -1,4 +0,5 @@ | ||
var events = require('./events')(require('./v3')) | ||
var Stream = require('./stream')(events) | ||
var progress = require('./progress') | ||
const Events = require('./events') | ||
const v3 = require('./v3') | ||
const StreamModule = require('./stream') | ||
const progress = require('./progress') | ||
@@ -10,2 +11,5 @@ function timestamp () { | ||
module.exports = function (opts) { | ||
const events = Events(v3) | ||
const Stream = StreamModule(events) | ||
var state = events.initialize(opts.id, opts.getMsgAuthor, opts.getMsgSequence) | ||
@@ -44,6 +48,6 @@ state.timeout = opts.timeout || 3000 | ||
createStream: function (remote_id, version, client) { | ||
if(this.streams[remote_id]) | ||
this.streams[remote_id].end(new Error('reconnected to peer')) | ||
if(this.logging) console.log('EBT:conn', remote_id) | ||
var stream = this.streams[remote_id] = new Stream(this, remote_id, version, client, opts.isMsg, function (peerState) { | ||
if(self.streams[remote_id]) | ||
self.streams[remote_id].end(new Error('reconnected to peer')) | ||
if(self.logging) console.log('EBT:conn', remote_id) | ||
var stream = self.streams[remote_id] = new Stream(this, remote_id, version, client, opts.isMsg, function (peerState) { | ||
opts.setClock(remote_id, peerState.clock) | ||
@@ -80,4 +84,4 @@ }) | ||
//for that peer/stream. | ||
for(var peer in this.state.peers) { | ||
var state = this.state.peers[peer] | ||
for(var peer in self.state.peers) { | ||
var state = self.state.peers[peer] | ||
while(state.retrive.length) { | ||
@@ -89,10 +93,10 @@ var id = state.retrive.shift() | ||
sequence:state.replicating[id].sent+1 | ||
}, this._retrive) | ||
}, self._retrive) | ||
} | ||
} | ||
if(this.state.receive.length) { | ||
var ev = this.state.receive.shift() | ||
if(self.state.receive.length) { | ||
var ev = self.state.receive.shift() | ||
opts.append(ev.value, function (err) { | ||
if(err) { | ||
if(this.logging) console.error('EBT:err', err) | ||
if(self.logging) console.error('EBT:err', err) | ||
self.block(ev.value.author, ev.id, true) | ||
@@ -103,4 +107,4 @@ } | ||
} | ||
for(var k in this.streams) | ||
this.streams[k].resume() | ||
for(var k in self.streams) | ||
self.streams[k].resume() | ||
}, | ||
@@ -107,0 +111,0 @@ } |
{ | ||
"name": "epidemic-broadcast-trees", | ||
"description": "bandwidth efficient broadcast gossip", | ||
"version": "8.0.6", | ||
"version": "8.0.7", | ||
"homepage": "https://github.com/dominictarr/epidemic-broadcast-trees", | ||
@@ -6,0 +6,0 @@ "repository": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
105290
2407