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

Commit 6249261

Browse files
committed
fix: wip
1 parent 94191fc commit 6249261

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

src/core/components/libp2p.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,18 @@ module.exports = function libp2p (self) {
1414
return callback(err)
1515
}
1616

17+
let modules = self._options.libp2p && self._options.libp2p.modules
18+
? self._options.libp2p.modules
19+
: undefined
20+
// TODO fix: the self._options.libp2p.modules is being messed up
21+
console.log('2 =>:', modules)
22+
1723
const options = {
1824
mdns: get(config, 'Discovery.MDNS.Enabled'),
1925
webRTCStar: get(config, 'Discovery.webRTCStar.Enabled'),
2026
bootstrap: get(config, 'Bootstrap'),
2127
dht: get(self._options, 'EXPERIMENTAL.dht'),
22-
modules: get(self._options, 'libp2p.modules')
28+
modules: modules
2329
}
2430

2531
self._libp2pNode = new Node(self._peerInfo, self._peerInfoBook, options)

src/http-api/index.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,18 @@ function HttpApi (repo, config) {
3232

3333
series([
3434
(cb) => {
35-
const libp2p = {
36-
modules: {}
37-
}
35+
const libp2p = { modules: {} }
3836

3937
// Attempt to use any of the WebRTC versions available globally
4038
let electronWebRTC
4139
let wrtc
4240
try { electronWebRTC = require('electron-webrtc')() } catch (err) {}
4341
try { wrtc = require('wrtc') } catch (err) {}
4442

45-
if (electronWebRTC || wrtc) {
46-
const wstar = new WStar(electronWebRTC || wrtc)
43+
console.log(!!wrtc, !!electronWebRTC)
44+
if (wrtc || electronWebRTC) {
45+
const wstar = new WStar({ wrtc: (wrtc || electronWebRTC) })
46+
console.log('1 =>:', wstar)
4747
libp2p.modules.transport = [wstar]
4848
libp2p.modules.discovery = [wstar.discovery]
4949
}
@@ -59,7 +59,8 @@ function HttpApi (repo, config) {
5959
EXPERIMENTAL: {
6060
pubsub: true,
6161
sharding: config && config.enableShardingExperiment
62-
}
62+
},
63+
libp2p: libp2p
6364
})
6465
} catch (err) {
6566
return cb(err)

0 commit comments

Comments
 (0)