fix: event emitter and interfaces types for discovery and routing (#934)

This commit is contained in:
Vasco Santos
2021-04-30 13:20:12 +02:00
committed by GitHub
parent f860ffb3e7
commit 302bb90058
11 changed files with 23 additions and 18 deletions

View File

@ -137,7 +137,12 @@ class Upgrader {
* @returns {Promise<Connection>}
*/
async upgradeOutbound (maConn) {
const remotePeerId = PeerId.createFromB58String(maConn.remoteAddr.getPeerId())
const idStr = maConn.remoteAddr.getPeerId()
if (!idStr) {
throw errCode(new Error('outbound connection must have a peer id'), codes.ERR_INVALID_MULTIADDR)
}
const remotePeerId = PeerId.createFromB58String(idStr)
let encryptedConn
let remotePeer