1.0.0 • Published 5 years ago
libp2p-signalhub v1.0.0
libp2p-signalhub
peer discovery for libp2p using signalhubs
Install - Usage - License: Apache-2.0
Install
npm install libp2p-signalhub
Usage
var Signalhub = require('libp2p-signalhub')
new Libp2p({
modules: {
peerDiscovery: [Signalhub]
},
config: {
peerDiscovery: {
signalhub: {
appName: 'your-app-name',
hubs: ['https://signalhub.myapp.org']
}
}
}
})
API
node = new Signalhub(opts)
Create a new peer discover node.
opts.appName
- required, name of your application, so different apps on one signalhub don't interfereopts.channel
- channel name for broadcasts, default 'libp2p-discover'opts.peerInfo
- PeerInfo instance, normally passed in by libp2p itselfopts.broadcast
- whether to broadcast the local multiaddresses to the signalhub, allowing other nodes to find you, defaultfalse
opts.interval
- broadcast interval in ms, default 10 secondsopts.hubs
- array of signalhub HTTP URLs to subscribe/broadcast to
node.start(cb)
Start listening for other peers (and broadcasting if opts.broadcast
).
cb
is called with an error if the subscription could not be started.
node.stop(cb)
Stop listening and broadcasting.
node.on('peer', function(peerInfo))
Event emitted when a new peer is discovered. peerInfo
is a PeerInfo instance.
License
1.0.0
5 years ago