mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-07-05 03:41:33 +00:00
Do not allow undefined peerInfo
# What The code assumes that `peerInfo` exists, the API doesn't. # How to test ```js swarm = new Swarm() swarm.addTransport('tcp', tcp, { multiaddr: mh }, {}, {port: 8095}) ``` This shouldn't explode because of `self.peerInfo.multiaddrs`.
This commit is contained in:
@ -11,6 +11,10 @@ function Swarm (peerInfo) {
|
||||
throw new Error('Swarm must be called with new')
|
||||
}
|
||||
|
||||
if (!peerInfo) {
|
||||
throw new Error('You must provide a value for `peerInfo`')
|
||||
}
|
||||
|
||||
self.peerInfo = peerInfo
|
||||
|
||||
// peerIdB58: { conn: <conn> }
|
||||
|
Reference in New Issue
Block a user