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 5.0.2 to 5.0.3

22

events.js

@@ -114,2 +114,8 @@

function isAhead(seq1, seq2) {
if(seq2 === -1) return false
if(seq2 == null) return true
if(seq1 > seq2) return true
}
exports.append = function (state, msg) {

@@ -124,2 +130,3 @@ //check if any peer requires this msg

var rep = peer.replicating[msg.author]
if(rep && rep.tx && rep.sent == msg.sequence - 1 && msg.sequence > peer.clock[msg.author]) {

@@ -130,5 +137,12 @@ peer.msgs.push(msg)

//if we are ahead of this peer, and not in tx mode, let them know that.
else if(rep && !rep.tx && msg.sequence > peer.clock[msg.author]) {
else if(
isAhead(msg.sequence, peer.clock[msg.author]) &&
( rep
? !rep.tx && rep.sent != null
: state.follows[msg.author]
)
) {
peer.notes = peer.notes || {}
peer.notes[msg.author] = ~msg.sequence
}

@@ -227,1 +241,7 @@ }

2

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

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

@@ -329,2 +329,23 @@ var test = require('tape')

test('connects in sync then another message', function (t) {
var state = {
clock: { alice: 3, bob: 2},
follows: { alice: true, bob: true},
peers: {}
}
state = events.connect(state, {id: 'bob'})
state = events.peerClock(state, {id: 'bob', value:{alice: 3, bob: 2}})
t.deepEqual(state.peers.bob.clock, {alice: 3, bob: 2})
t.deepEqual(state.peers.bob.notes, {})
//receive empty clock
state = events.notes(state, {id: 'bob', value: {}})
t.deepEqual(state.peers.bob.replicating, {})
state = events.append(state, {author: 'alice', sequence: 4, content: {}})
t.deepEqual(state.peers.bob.notes, {alice: ~4})
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