mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-03-30 15:08:28 +00:00
13 lines
395 B
JavaScript
13 lines
395 B
JavaScript
export default (ipfs, peersToWait, topic, callback) => {
|
|
return new Promise((resolve, reject) => {
|
|
const i = setInterval(async () => {
|
|
const peers = await ipfs.pubsub.peers(topic)
|
|
const hasAllPeers = peersToWait.map((e) => peers.includes(e)).filter((e) => e === false).length === 0
|
|
if (hasAllPeers) {
|
|
clearInterval(i)
|
|
resolve()
|
|
}
|
|
}, 500)
|
|
})
|
|
}
|