Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

Commit

Permalink
fix: wip
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Jun 29, 2017
1 parent 94191fc commit 6249261
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
8 changes: 7 additions & 1 deletion src/core/components/libp2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 7 additions & 6 deletions src/http-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@ function HttpApi (repo, config) {

series([
(cb) => {
const libp2p = {
modules: {}
}
const libp2p = { modules: {} }

// Attempt to use any of the WebRTC versions available globally
let electronWebRTC
let wrtc
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]
}
Expand All @@ -59,7 +59,8 @@ function HttpApi (repo, config) {
EXPERIMENTAL: {
pubsub: true,
sharding: config && config.enableShardingExperiment
}
},
libp2p: libp2p
})
} catch (err) {
return cb(err)
Expand Down

0 comments on commit 6249261

Please sign in to comment.