feat: allow transport options to be passed on creation (#524)

* feat: allow transport options to be passed on creation

* fix: only add circuit transport if enabled

* chore: fix lint
This commit is contained in:
Jacob Heun
2019-12-20 08:32:46 -08:00
parent 7b326cc525
commit c339be10ee
5 changed files with 70 additions and 5 deletions

View File

@ -26,9 +26,10 @@ class TransportManager {
*
* @param {String} key
* @param {Transport} Transport
* @param {*} transportOptions Additional options to pass to the transport
* @returns {void}
*/
add (key, Transport) {
add (key, Transport, transportOptions = {}) {
log('adding %s', key)
if (!key) {
throw errCode(new Error(`Transport must have a valid key, was given '${key}'`), codes.ERR_INVALID_KEY)
@ -38,6 +39,7 @@ class TransportManager {
}
const transport = new Transport({
...transportOptions,
libp2p: this.libp2p,
upgrader: this.upgrader
})