mirror of
https://github.com/orbitdb/orbitdb.git
synced 2025-06-23 22:42:30 +00:00
Check for store before emitting event
This commit is contained in:
parent
eb6c1c2ead
commit
a03e062c60
@ -254,10 +254,12 @@ class OrbitDB {
|
|||||||
const store = this.stores[address]
|
const store = this.stores[address]
|
||||||
try {
|
try {
|
||||||
logger.debug(`Received ${heads.length} heads for '${address}':\n`, JSON.stringify(heads.map(e => e.hash), null, 2))
|
logger.debug(`Received ${heads.length} heads for '${address}':\n`, JSON.stringify(heads.map(e => e.hash), null, 2))
|
||||||
if (store && heads && heads.length > 0) {
|
if (store && heads) {
|
||||||
await store.sync(heads)
|
if (heads.length > 0) {
|
||||||
|
await store.sync(heads)
|
||||||
|
}
|
||||||
|
store.events.emit('peer.exchanged', peer, address, heads)
|
||||||
}
|
}
|
||||||
store.events.emit('peer.exchanged', peer, address, heads)
|
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user