feat: add explicit error for case peer id not included in multiaddr (#155)

This commit is contained in:
Chris Dostert
2018-02-05 03:36:20 -08:00
committed by David Dias
parent 248d86d050
commit bd8a35aaf9
2 changed files with 6 additions and 1 deletions

View File

@ -319,7 +319,12 @@ class Node extends EventEmitter {
if (typeof peer === 'string') {
peer = multiaddr(peer)
}
const peerIdB58Str = peer.getPeerId()
if (!peerIdB58Str) {
throw new Error(`peer multiaddr instance or string must include peerId`)
}
try {
p = this.peerBook.get(peerIdB58Str)
} catch (err) {