fix: always emit when a connection is made

This commit is contained in:
Jacob Heun 2020-05-27 18:08:53 +02:00
parent 52a615f922
commit 72f37acd4a

View File

@ -175,11 +175,11 @@ class ConnectionManager extends EventEmitter {
const peerIdStr = peerId.toB58String() const peerIdStr = peerId.toB58String()
const storedConn = this.connections.get(peerIdStr) const storedConn = this.connections.get(peerIdStr)
this.emit('peer:connect', connection)
if (storedConn) { if (storedConn) {
storedConn.push(connection) storedConn.push(connection)
} else { } else {
this.connections.set(peerIdStr, [connection]) this.connections.set(peerIdStr, [connection])
this.emit('peer:connect', connection)
} }
this._libp2p.peerStore.keyBook.set(peerId, peerId.pubKey) this._libp2p.peerStore.keyBook.set(peerId, peerId.pubKey)