fix: remove peer discovery module config checks

Configuration for the peer discovery modules is now optional so this does not need to be validated. This also cleans up the config module to reduce repetition.

License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
This commit is contained in:
Alan Shaw
2018-06-28 16:06:42 +01:00
committed by Jacob Heun
parent 1af5ba9093
commit 4ad70efb00
3 changed files with 16 additions and 69 deletions

View File

@ -34,8 +34,8 @@ class Node extends EventEmitter {
this.peerInfo = _options.peerInfo
this.peerBook = _options.peerBook || new PeerBook()
this._modules = _options.modules || {}
this._config = _options.config || {}
this._modules = _options.modules
this._config = _options.config
this._isStarted = false
this._transport = [] // Transport instances/references
this._discovery = [] // Discovery service instances/references
@ -76,7 +76,7 @@ class Node extends EventEmitter {
}
// dht provided components (peerRouting, contentRouting, dht)
if (this._config.EXPERIMENTAL && this._config.EXPERIMENTAL.dht) {
if (this._config.EXPERIMENTAL.dht) {
const DHT = this._modules.dht
this._dht = new DHT(this._switch, {
kBucketSize: this._config.dht.kBucketSize || 20,
@ -87,7 +87,7 @@ class Node extends EventEmitter {
}
// enable/disable pubsub
if (this._config.EXPERIMENTAL && this._config.EXPERIMENTAL.pubsub) {
if (this._config.EXPERIMENTAL.pubsub) {
this.pubsub = pubsub(this)
}