npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

solyd-gossip

v0.0.1

Published

distributed, secure, transport agnostic message gossip protocol

Downloads

3

Readme

solyd-gossip

Encrypted, transport agnostic, message gossip protocol.

Any peer in the network can publish messages, which will eventually propogate out to the entire network via rounds of gossip between each node's peers.

Security

Each published message is signed with the peer's private key, using solyd-keys. This means messages cannot be forged -- you can be sure that the messages you receive are from the peer that it claims to be, even if it came in from an intermediary.

Example

Let's create a line of 3 peers and watch a published message propogate through them:

var gossip = require('solyd-gossip')

var peer1 = gossip()
var peer2 = gossip()
var peer3 = gossip()

var p1 = peer1.createPeerStream()
var p2_1 = peer2.createPeerStream()
var p2_2 = peer2.createPeerStream()
var p3 = peer3.createPeerStream()

// 3 peers in a line, with peer-2 in the middle
p1.pipe(p2_1).pipe(p1)
p2_2.pipe(p3).pipe(p2_2)

// have p1 publish, and watch it propogate to p2 and then p3
peer1.publish({
  data: 'hello warld'
})

peer1.on('message', function (msg, info) {
  console.log('p1 message', msg, 'from', info.public)
})

peer2.on('message', function (msg, info) {
  console.log('p2 message', msg, 'from', info.public)
})

peer3.on('message', function (msg, info) {
  console.log('p3 message', msg, 'from', info.public)
})

outputs

p2 message { data: "hello warld" } from UHXoKlI2blLU0GaAC3G2sUSGBUOWY7yYpN7DhWQI2/Y=.ed25519

p3 message { data: "hello warld" }  from UHXoKlI2blLU0GaAC3G2sUSGBUOWY7yYpN7DhWQI2/Y=.ed25519

API

var gossip = require('solyd-gossip')

var peer = gossip(opts={})

Returns a new gossiping peer. Accepts various options via opts:

  • keys - uses keypair keys for message signing. You can generate these keys yourself (using ssb-keys), or, if not given, a fresh keypair will be generated for you.
  • interval- how often to perform gossip with peers, in milliseconds. Defaults to 100ms. If set to -1, no automatic gossip will occur and you'll need to run peer.gossip() manually.

peer.createPeerStream()

Returns a new duplex stream that can be used to exchange gossip with another peer.

Remember: create a new peer stream per pair of peers!

peer.publish(msg)

Publish a signed message to all of your peers.

peer.gossip()

Initiate a round of gossip manually, forwarding all stored messages to peers.

peer.stop()

Stops gossiping (clears the internal setInterval timer).

peer.on('message', function (msg, info) {})

Event fired when a message is received from a peer.

  • msg is the original payload from the peer
  • info is an object, currently only having the field public, which is a string of the sender's public key

install

With npm installed, run

$ npm install solyd-gossip

license

ISC