From 6249261a4f975342205b9c8570ead837e1c25b51 Mon Sep 17 00:00:00 2001 From: David Dias Date: Thu, 29 Jun 2017 16:36:15 +0100 Subject: [PATCH] fix: wip --- src/core/components/libp2p.js | 8 +++++++- src/http-api/index.js | 13 +++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/core/components/libp2p.js b/src/core/components/libp2p.js index 1cc3ed490a..17158a9da8 100644 --- a/src/core/components/libp2p.js +++ b/src/core/components/libp2p.js @@ -14,12 +14,18 @@ module.exports = function libp2p (self) { return callback(err) } + let modules = self._options.libp2p && self._options.libp2p.modules + ? self._options.libp2p.modules + : undefined + // TODO fix: the self._options.libp2p.modules is being messed up + console.log('2 =>:', modules) + const options = { mdns: get(config, 'Discovery.MDNS.Enabled'), webRTCStar: get(config, 'Discovery.webRTCStar.Enabled'), bootstrap: get(config, 'Bootstrap'), dht: get(self._options, 'EXPERIMENTAL.dht'), - modules: get(self._options, 'libp2p.modules') + modules: modules } self._libp2pNode = new Node(self._peerInfo, self._peerInfoBook, options) diff --git a/src/http-api/index.js b/src/http-api/index.js index cd8106657d..1b4218d858 100644 --- a/src/http-api/index.js +++ b/src/http-api/index.js @@ -32,9 +32,7 @@ function HttpApi (repo, config) { series([ (cb) => { - const libp2p = { - modules: {} - } + const libp2p = { modules: {} } // Attempt to use any of the WebRTC versions available globally let electronWebRTC @@ -42,8 +40,10 @@ function HttpApi (repo, config) { try { electronWebRTC = require('electron-webrtc')() } catch (err) {} try { wrtc = require('wrtc') } catch (err) {} - if (electronWebRTC || wrtc) { - const wstar = new WStar(electronWebRTC || wrtc) + console.log(!!wrtc, !!electronWebRTC) + if (wrtc || electronWebRTC) { + const wstar = new WStar({ wrtc: (wrtc || electronWebRTC) }) + console.log('1 =>:', wstar) libp2p.modules.transport = [wstar] libp2p.modules.discovery = [wstar.discovery] } @@ -59,7 +59,8 @@ function HttpApi (repo, config) { EXPERIMENTAL: { pubsub: true, sharding: config && config.enableShardingExperiment - } + }, + libp2p: libp2p }) } catch (err) { return cb(err)