Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

epidemic-broadcast-trees

Package Overview
Dependencies
Maintainers
1
Versions
47
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

epidemic-broadcast-trees - npm Package Compare versions

Comparing version 6.3.3 to 6.3.4

11

events.js

@@ -109,5 +109,6 @@ 'use strict'

if(state.peers[ev.id]) throw new Error('already connected to peer:'+ev.id)
if(isBlocked(state, state.id, ev.id)) return state
// if(isBlocked(state, state.id, ev.id)) return state
state.peers[ev.id] = {
blocked: isBlocked(state, state.id, ev.id),
clock: null,

@@ -432,2 +433,3 @@ client: !!ev.client,

exports.block = function (state, ev) {
//also, check wether we are currently connected to a blocked peer.
if(!ev.value) {

@@ -443,2 +445,7 @@ if(state.blocks[ev.id]) delete state.blocks[ev.id][ev.target]

if(state.peers[ev.target]) {
//end replication immediately.
state.peers[ev.target].blocked = ev.value
}
for(var id in state.peers) {

@@ -469,1 +476,3 @@ var peer = state.peers[id]

2

package.json
{
"name": "epidemic-broadcast-trees",
"description": "",
"version": "6.3.3",
"version": "6.3.4",
"homepage": "https://github.com/dominictarr/epidemic-broadcast-trees",

@@ -6,0 +6,0 @@ "repository": {

@@ -83,4 +83,7 @@ var inherits = require('inherits')

this.sink &&
!this.sink.paused && (
state.msgs.length || state.notes
!this.sink.paused &&
!this.ended && (
//missing state means this peer was blocked,
//end immediately.
state.blocked || state.msgs.length || state.notes
)

@@ -94,3 +97,5 @@ )

while(this.canSend()) {
if(state.msgs.length) {
if(state.blocked)
this.end()
else if(state.msgs.length) {
if(this.peer.logging) console.error("EBT:send", JSON.stringify(state.msgs[0], null, 2))

@@ -121,1 +126,2 @@ this.sink.write(state.msgs.shift())

@@ -29,3 +29,3 @@

t.deepEqual(state.peers, {})
t.equal(state.peers.bob.blocked, true)

@@ -56,1 +56,2 @@ state = events.connect(state, {id: 'dawn', client: false})

@@ -158,1 +158,74 @@ var createPeer = require('../')

test('a<-!>b', function (t) {
var alice = create('alice')
var bob = create('bob')
alice.request('alice', true)
alice.request('bob', true)
alice.block('alice', 'bob', true)
bob.request('alice', true)
bob.request('bob', true)
var as = alice.createStream('bob', 3, false)
var bs = bob.createStream('alice', 3, true)
as.pipe(bs).pipe(as)
t.equal(as.ended, true)
t.equal(bs.ended, true)
t.end()
})
test('a<->b...!', function (t) {
var alice = create('alice')
var bob = create('bob')
alice.request('alice', true)
alice.request('bob', true)
bob.request('alice', true)
bob.request('bob', true)
var as = alice.createStream('bob', 3, false)
var bs = bob.createStream('alice', 3, true)
as.pipe(bs).pipe(as)
t.equal(as.ended, false)
t.equal(bs.ended, false)
alice.block('alice', 'bob', true)
console.log(as.peer.state)
t.equal(as.ended, true)
t.equal(bs.ended, true)
t.end()
})
test('b<-!->a', function (t) {
var alice = create('alice')
var bob = create('bob')
alice.request('alice', true)
alice.request('bob', true)
alice.block('alice', 'bob', true)
bob.request('alice', true)
bob.request('bob', true)
var as = alice.createStream('bob', 3, true)
var bs = bob.createStream('alice', 3, false)
as.pipe(bs).pipe(as)
t.equal(as.ended, true)
t.equal(bs.ended, true)
t.end()
})
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc