mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-06-07 14:46: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 () => {
|
const startSync = async () => {
|
||||||
// Exchange head entries with peers when connected
|
if (!started) {
|
||||||
await ipfs.libp2p.handle(headsSyncAddress, handleReceiveHeads)
|
// Exchange head entries with peers when connected
|
||||||
ipfs.libp2p.pubsub.addEventListener('subscription-change', handlePeerSubscribed)
|
await ipfs.libp2p.handle(headsSyncAddress, handleReceiveHeads)
|
||||||
// Subscribe to the pubsub channel for this database through which updates are sent
|
ipfs.libp2p.pubsub.addEventListener('subscription-change', handlePeerSubscribed)
|
||||||
await ipfs.pubsub.subscribe(address, handleUpdateMessage)
|
// Subscribe to the pubsub channel for this database through which updates are sent
|
||||||
started = true
|
await ipfs.pubsub.subscribe(address, handleUpdateMessage)
|
||||||
|
started = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start Sync automatically
|
// Start Sync automatically
|
||||||
|
Loading…
x
Reference in New Issue
Block a user