libp2p-pstn-topo-partialmesh
v0.0.2
Published
Partial mesh topology for connecting nodes in a js-libp2p-pstn (pubsub testnet) instance
Downloads
1
Maintainers
Readme
js libp2p pstn topo partialmesh
A partial mesh topology for use in libp2p pubsub testing.
Install
To install through npm:
> npm i libp2p-pstn-topo-partialmesh --save
Example
libp2p-pstn-topo-partialmesh
works as a topology for the js-libp2p pubsub testnet. It fits into the libp2p-pstn-topo-*
ecosystem.
const createTopo = require('libp2p-pstn-topo-partialmesh')
// Note: nodes must adhere to this interface:
// { peerInfo: <peerInfo>, libp2p: <libp2p> }
const nodes = [nodeA, nodeB, ..., nodeN]
createTopo(nodes).then((connectedNodes) => {
// your nodes are now connected in a partial mesh topology
// currently 2 connections are initialized per peer
})
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
Note: Currently, peers make 2 connections to the mesh at random.
Tests
To run the basic tests:
> npm test
Contribute
PRs are welcome!
License
MIT © Gavin McDermott