Merge pull request #50 from orbitdb/fix/browser-tests

Fix Sync state
This commit is contained in:
Haad
2023-03-26 08:42:01 +03:00
committed by GitHub

View File

@@ -153,12 +153,14 @@ const Sync = async ({ ipfs, log, events, onSynced, start }) => {
}
const startSync = async () => {
// Exchange head entries with peers when connected
await ipfs.libp2p.handle(headsSyncAddress, handleReceiveHeads)
ipfs.libp2p.pubsub.addEventListener('subscription-change', handlePeerSubscribed)
// Subscribe to the pubsub channel for this database through which updates are sent
await ipfs.pubsub.subscribe(address, handleUpdateMessage)
started = true
if (!started) {
// Exchange head entries with peers when connected
await ipfs.libp2p.handle(headsSyncAddress, handleReceiveHeads)
ipfs.libp2p.pubsub.addEventListener('subscription-change', handlePeerSubscribed)
// Subscribe to the pubsub channel for this database through which updates are sent
await ipfs.pubsub.subscribe(address, handleUpdateMessage)
started = true
}
}
// Start Sync automatically