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

fix: wip #885

Merged
merged 1 commit into from
Jun 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/core/components/libp2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ module.exports = function libp2p (self) {
webRTCStar: get(config, 'Discovery.webRTCStar.Enabled'),
bootstrap: get(config, 'Bootstrap'),
dht: get(self._options, 'EXPERIMENTAL.dht'),
modules: get(self._options, 'libp2p.modules')
modules: self._libp2pModules
}

self._libp2pNode = new Node(self._peerInfo, self._peerInfoBook, options)
Expand Down
1 change: 1 addition & 0 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class IPFS extends EventEmitter {
}

options = options || {}
this._libp2pModules = options.libp2p && options.libp2p.modules

extend(this._options, options)

Expand Down
11 changes: 5 additions & 6 deletions src/http-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,16 @@ 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)
if (wrtc || electronWebRTC) {
const wstar = new WStar({ wrtc: (wrtc || electronWebRTC) })
libp2p.modules.transport = [wstar]
libp2p.modules.discovery = [wstar.discovery]
}
Expand All @@ -59,7 +57,8 @@ function HttpApi (repo, config) {
EXPERIMENTAL: {
pubsub: true,
sharding: config && config.enableShardingExperiment
}
},
libp2p: libp2p
})
} catch (err) {
return cb(err)
Expand Down