RemoteNetworker
API Docs | https://github.com/hypercore-protocol/hyperspace-client#remote-networker |
The API for the Hyperspace daemon "corestore networker."
const { Client: HyperspaceClient } = require('@hyperspace')
const client = new HyperspaceClient() // connect to the Hyperspace server
await client.ready() // wait for .peers to be populated
// get current peers
console.log(client.networker.peers)
// log peer events
client.networker.on('peer-add', peer => {
console.log('New peer:', peer)
})
client.networker.on('peer-remove', peer => {
console.log('Peer disconnected:', peer)
})
// seed `myHypercore`
await client.networker.configure(myHypercore, {announce: true, lookup: true})
// ...which is equiv to:
await client.replicate(myHypercore)