用于连接对等体的分布式网络栈。
一个高级别的 API,用于查找和连接到对"主题"感兴趣的对等节点。
npm install hyperswarmconst Hyperswarm = require('hyperswarm')
const swarm = new Hyperswarm()
swarm1.on('connection', (conn) => {
// swarm1 will receive server connections
conn.write('this is a server connection')
conn.end()
})
const discoveryKey = Buffer.alloc(32).fill('hello world') // must be 32 bytes
// join the swarm, others will find you
swarm2.join(discoveryKey, { server: true, client: true })const swarm = new Hyperswarm(opts = {})构建新的 Hyperswarm 实例。
opts 可以包括:
keyPair: 用于监听/连接 DHT 的 Noise 密钥对。默认为新的密钥对。swarm.dht 是一个 hyperdht 实例。如果您希望对 Hyperswarm 的网络进行更低级别的控制,则非常有用。
暂无开放 Issues,或尚未同步最近议题。