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:
Pau Ramon Revilla
2015-09-25 09:26:50 +02:00
parent cd53344441
commit 0514b0034b
3 changed files with 14 additions and 1 deletions

View File

@ -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> }