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

@nabladelta/lambdadelta

v0.2.1

Published

P2P Event Feed

Downloads

5

Readme

Lambdadelta

P2P Event Feed secured by RLN proofs

npm i @nabladelta/lambdadelta

Built on js-libp2p and secured by the Rate Limiting Nullifier. Provides a decentralized, peer to peer, (optionally) permissionless multiwriter event feed that is both anonymous and private, which can be used as a platform to build many kinds of decentralized applications.

Usage

To try it out, you need to create an RLN group, instantiate a Lambdadelta instance, and add messages to it.

import { gossipsub } from '@chainsafe/libp2p-gossipsub'
import { noise } from '@chainsafe/libp2p-noise'
import { yamux } from '@chainsafe/libp2p-yamux'
import { mplex } from '@libp2p/mplex'
import { tcp } from '@libp2p/tcp'
import { GroupDataProvider, MemoryProvider, RLN } from '@nabladelta/rln'
import { createLibp2p } from 'libp2p'
import { identifyService } from 'libp2p/identify'
import { MemoryDatastore } from 'datastore-core'
import { Identity } from '@semaphore-protocol/identity'
import { Logger } from "tslog"
import delay from "delay"
import { kadDHT } from '@libp2p/kad-dht'
import { Lambdadelta } from "@nabladelta/lambdadelta"

Create libp2p nodes:

const createNode = async () => {
  const node = await createLibp2p({
    addresses: {
      listen: ['/ip4/0.0.0.0/tcp/0']
    },
    transports: [tcp()],
    streamMuxers: [yamux(), mplex()],
    connectionEncryption: [noise()],
    services: {
      pubsub: gossipsub({
        allowPublishToZeroPeers: true
        }),
      identify: identifyService(),
      dht: kadDHT({
        allowQueryWithZeroPeers: true,
      })
    }
  })

  return node
}

const libp2p = await createNode()
const libp2pB = await createNode()

await libp2p.peerStore.patch(libp2pB.peerId, {
    multiaddrs: libp2pB.getMultiaddrs()
})

await libp2pB.peerStore.patch(libp2p.peerId, {
    multiaddrs: libp2p.getMultiaddrs()
})
await libp2p.start()
await libp2pB.start()

await libp2p.dial(libp2pB.peerId)
await libp2pB.dial(libp2p.peerId)

Initialize the nodes, ensuring they are part of the same group and share a common gid:

const secretA = 'secret1secret1secret1'
const secretB = 'secret1secret1secret2'
const gData = MemoryProvider.write(
[
    GroupDataProvider.createEvent(new Identity(secretA).commitment, 2),
    GroupDataProvider.createEvent(new Identity(secretB).commitment),
], undefined)

const rlnstore = new MemoryDatastore()
const rlnstoreB = new MemoryDatastore()
const rln = await RLN.loadMemory(secretA, gData, rlnstore)
const rlnB = await RLN.loadMemory(secretB, gData, rlnstoreB)

const nodeA = await Lambdadelta.create({topic: 'a', groupID: '1', rln, libp2p})
const nodeB = await Lambdadelta.create({topic: 'a', groupID: '1', rln: rlnB, libp2p: libp2pB})

Start producing new events:

await nodeA.newEvent('POST', 'hello world')

After a while events propagate to all nodes that have joined the topic:

await delay(2000)
console.log((await nodeA.getEvents()).map(e => e.header.payloadHash))