Check for store before emitting event

This commit is contained in:
Tyler Yasaka 2018-11-29 02:06:00 -08:00 committed by Michael Sterle-Contala
parent eb6c1c2ead
commit a03e062c60
No known key found for this signature in database
GPG Key ID: 93B73CB655B6E809

View File

@ -254,10 +254,12 @@ class OrbitDB {
const store = this.stores[address]
try {
logger.debug(`Received ${heads.length} heads for '${address}':\n`, JSON.stringify(heads.map(e => e.hash), null, 2))
if (store && heads && heads.length > 0) {
await store.sync(heads)
if (store && 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) {
logger.error(e)
}