Skip to content

Ring topology for connecting nodes in a js-libp2p-pstn testnet instance

Notifications You must be signed in to change notification settings

gavinmcdermott/js-libp2p-pstn-topo-ring

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

js libp2p pstn topo ring

A ring topology for use in libp2p pubsub testing.

Install

To install through npm:

> npm i libp2p-pstn-topo-ring --save

Example

libp2p-pstn-topo-ring works as a topology for the js-libp2p pubsub testnet. It fits into the libp2p-pstn-topo-* ecosystem.

const createRing = require('libp2p-pstn-topo-ring')

// Note: nodes must adhere to this interface:
// { peerInfo: <peerInfo>, libp2p: <libp2p> }
const nodes = [nodeA, nodeB, ..., nodeN]

createRing(nodes).then((connectedNodes) => {
  // your nodes are now connected in a ring topology
})

API

The exported function takes an array of nodes, where nodes are structured as follows:

node = {
  peerInfo: <peerInfo>, 
  libp2p: <libp2p>
}

And the function returns a promise containing an array of now-connected nodes:

const create = require('libp2p-pstn-topo-partialmesh')
const nodes = [nodeA, nodeB, ..., nodeN]
create(nodes).then((connected) => /* do something */)

Tests

To run the basic tests:

> npm test

Contribute

PRs are welcome!

License

MIT © Gavin McDermott

About

Ring topology for connecting nodes in a js-libp2p-pstn testnet instance

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published