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
@ -153,6 +153,7 @@ const Sync = async ({ ipfs, log, events, onSynced, start }) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const startSync = async () => {
|
const startSync = async () => {
|
||||||
|
if (!started) {
|
||||||
// Exchange head entries with peers when connected
|
// Exchange head entries with peers when connected
|
||||||
await ipfs.libp2p.handle(headsSyncAddress, handleReceiveHeads)
|
await ipfs.libp2p.handle(headsSyncAddress, handleReceiveHeads)
|
||||||
ipfs.libp2p.pubsub.addEventListener('subscription-change', handlePeerSubscribed)
|
ipfs.libp2p.pubsub.addEventListener('subscription-change', handlePeerSubscribed)
|
||||||
@ -160,6 +161,7 @@ const Sync = async ({ ipfs, log, events, onSynced, start }) => {
|
|||||||
await ipfs.pubsub.subscribe(address, handleUpdateMessage)
|
await ipfs.pubsub.subscribe(address, handleUpdateMessage)
|
||||||
started = true
|
started = true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Start Sync automatically
|
// Start Sync automatically
|
||||||
if (start !== false) {
|
if (start !== false) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user