mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-06-15 18:46:36 +00:00
fix: Deregister all events to complete stop sync.
This commit is contained in:
parent
dc706ee713
commit
ec8b17352a
@ -256,6 +256,7 @@ const Sync = async ({ ipfs, log, events, onSynced, start, timeout }) => {
|
|||||||
if (started) {
|
if (started) {
|
||||||
await queue.onIdle()
|
await queue.onIdle()
|
||||||
ipfs.libp2p.services.pubsub.removeEventListener('subscription-change', handlePeerSubscribed)
|
ipfs.libp2p.services.pubsub.removeEventListener('subscription-change', handlePeerSubscribed)
|
||||||
|
ipfs.libp2p.services.pubsub.removeEventListener('message', handleUpdateMessage)
|
||||||
await ipfs.libp2p.unhandle(headsSyncAddress)
|
await ipfs.libp2p.unhandle(headsSyncAddress)
|
||||||
await ipfs.libp2p.services.pubsub.unsubscribe(address)
|
await ipfs.libp2p.services.pubsub.unsubscribe(address)
|
||||||
peers.clear()
|
peers.clear()
|
||||||
|
@ -74,10 +74,12 @@ describe('Events Database Replication', function () {
|
|||||||
if (db1) {
|
if (db1) {
|
||||||
await db1.drop()
|
await db1.drop()
|
||||||
await db1.close()
|
await db1.close()
|
||||||
|
db1 = null
|
||||||
}
|
}
|
||||||
if (db2) {
|
if (db2) {
|
||||||
await db2.drop()
|
await db2.drop()
|
||||||
await db2.close()
|
await db2.close()
|
||||||
|
db2 = null
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -128,9 +130,6 @@ describe('Events Database Replication', function () {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('loads the database after replication', async () => {
|
it('loads the database after replication', async () => {
|
||||||
db1 = await Events()({ ipfs: ipfs1, identity: testIdentity1, address: databaseId, accessController, directory: './orbitdb1' })
|
|
||||||
db2 = await Events()({ ipfs: ipfs2, identity: testIdentity2, address: databaseId, accessController, directory: './orbitdb2' })
|
|
||||||
|
|
||||||
let replicated = false
|
let replicated = false
|
||||||
let expectedEntryHash = null
|
let expectedEntryHash = null
|
||||||
|
|
||||||
@ -146,6 +145,9 @@ describe('Events Database Replication', function () {
|
|||||||
console.error(err)
|
console.error(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
db1 = await Events()({ ipfs: ipfs1, identity: testIdentity1, address: databaseId, accessController, directory: './orbitdb1' })
|
||||||
|
db2 = await Events()({ ipfs: ipfs2, identity: testIdentity2, address: databaseId, accessController, directory: './orbitdb2' })
|
||||||
|
|
||||||
db2.events.on('join', onConnected)
|
db2.events.on('join', onConnected)
|
||||||
db2.events.on('update', onUpdate)
|
db2.events.on('update', onUpdate)
|
||||||
|
|
||||||
|
@ -39,20 +39,8 @@ export default async () => {
|
|||||||
pubsub: gossipsub({ allowPublishToZeroPeers: true })
|
pubsub: gossipsub({ allowPublishToZeroPeers: true })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const libp2p = await createLibp2p(options)
|
const libp2p = await createLibp2p(options)
|
||||||
/* const libp2p = await createLibp2p({
|
|
||||||
connectionGater: { denyDialMultiaddr: () => false },
|
|
||||||
transports: [webSockets({ filter: all }), webRTC()],
|
|
||||||
connectionEncryption: [noise()],
|
|
||||||
streamMuxers: [mplex()],
|
|
||||||
services: {
|
|
||||||
identify: identifyService(),
|
|
||||||
pubsub: gossipsub()
|
|
||||||
},
|
|
||||||
addresses: {
|
|
||||||
listen: [isBrowser() ? '/ip4/0.0.0.0/tcp/12345/ws/p2p-webrtc-star' : '/ip4/0.0.0.0/tcp/0/ws']
|
|
||||||
}
|
|
||||||
}) */
|
|
||||||
|
|
||||||
return await createHelia({ libp2p })
|
return await createHelia({ libp2p })
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user