hypercore-protocol / hypercore-next

Hypercore 10 is an append only log with multi-writer primitives built in.
MIT License
150 stars 15 forks source link

add done = core.findingPeers() hook #90

Closed mafintosh closed 2 years ago

mafintosh commented 2 years ago
const swarm = new Hyperswarm()
const core = new Hypercore(...)

swarm.on('connection', socket => core.replicate(socket))
swarm.join(...)

const done = core.findingPeers()

swarm.flush().then(done, done)

// waits for either 1st peer or the discovery hooks to finish
const updated await core.update()