fix: pass libp2p to discovery services (#597)

* fix: include libp2p in the options passed to discovery creation

* fix: handle multiple peer addresses in get multiaddrs for peers

* test(peer-store): add test to verify returned relay multiaddrs
This commit is contained in:
Jacob Heun
2020-03-31 13:43:27 +02:00
committed by GitHub
parent 30728753cf
commit 9e35fbc316
3 changed files with 9 additions and 5 deletions

View File

@ -243,7 +243,8 @@ class PeerStore extends EventEmitter {
*/
multiaddrsForPeer (peer) {
return this.put(peer, true).multiaddrs.toArray().map(addr => {
if (addr.getPeerId()) return addr
const idString = addr.getPeerId()
if (idString && idString === peer.id.toB58String()) return addr
return addr.encapsulate(`/p2p/${peer.id.toB58String()}`)
})
}