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

@ -114,10 +114,14 @@ class Libp2p extends EventEmitter {
})
this._modules.transport.forEach((Transport) => {
this.transportManager.add(Transport.prototype[Symbol.toStringTag], Transport)
const key = Transport.prototype[Symbol.toStringTag]
const transportOptions = this._config.transport[key]
this.transportManager.add(key, Transport, transportOptions)
})
// TODO: enable relay if enabled
this.transportManager.add(Circuit.prototype[Symbol.toStringTag], Circuit)
if (this._config.relay.enabled) {
this.transportManager.add(Circuit.prototype[Symbol.toStringTag], Circuit)
}
// Attach stream multiplexers
if (this._modules.streamMuxer) {