mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-06-04 21:26:37 +00:00
Fix Sync state
This commit is contained in:
parent
3f138ab98b
commit
2308f01a99
14
src/sync.js
14
src/sync.js
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user