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

Commit bdbe7ed

Browse files
committed
fix: tweak new config for test success
License: MIT Signed-off-by: Alan Shaw <[email protected]>
1 parent 9d9fb6f commit bdbe7ed

File tree

4 files changed

+81
-56
lines changed

4 files changed

+81
-56
lines changed

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161
},
6262
"homepage": "https://github.com/ipfs/js-ipfs#readme",
6363
"devDependencies": {
64-
"aegir": "^13.1.0",
64+
"aegir": "^14.0.0",
6565
"buffer-loader": "~0.0.1",
6666
"chai": "^4.1.2",
6767
"delay": "^2.0.0",
@@ -125,14 +125,14 @@
125125
"joi": "^13.2.0",
126126
"joi-browser": "^13.0.1",
127127
"joi-multiaddr": "^2.0.0",
128-
"libp2p": "~0.20.4",
128+
"libp2p": "~0.21.0",
129129
"libp2p-circuit": "~0.2.0",
130130
"libp2p-floodsub": "~0.15.0",
131131
"libp2p-kad-dht": "~0.10.0",
132132
"libp2p-keychain": "~0.3.1",
133-
"libp2p-mdns": "~0.11.0",
134-
"libp2p-mplex": "~0.7.0",
135-
"libp2p-railing": "~0.8.1",
133+
"libp2p-mdns": "~0.12.0",
134+
"libp2p-mplex": "~0.8.0",
135+
"libp2p-railing": "~0.9.1",
136136
"libp2p-secio": "~0.10.0",
137137
"libp2p-tcp": "~0.12.0",
138138
"libp2p-webrtc-star": "~0.15.0",

src/core/components/libp2p.js

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,20 @@ module.exports = function libp2p (self) {
2020
peerBook: self._peerInfoBook,
2121
modules: self._libp2pModules,
2222
config: {
23-
mdns: get(config, 'Discovery.MDNS.Enabled'),
24-
webRTCStar: get(config, 'Discovery.webRTCStar.Enabled'),
25-
bootstrap: get(config, 'Bootstrap')
26-
},
27-
EXPERIMENTAL: {
28-
// TODO move all of this to the config!
29-
pubsub: get(self._options, 'EXPERIMENTAL.pubsub', false),
30-
dht: get(self._options, 'EXPERIMENTAL.dht', false),
23+
peerDiscovery: {
24+
mdns: {
25+
enabled: get(self._options, 'config.Discovery.MDNS.Enabled',
26+
get(config, 'Discovery.MDNS.Enabled', true))
27+
},
28+
webRTCStar: {
29+
enabled: get(self._options, 'config.Discovery.webRTCStar.Enabled',
30+
get(config, 'Discovery.webRTCStar.Enabled', true))
31+
},
32+
bootstrap: {
33+
list: get(self._options, 'config.Bootstrap',
34+
get(config, 'Bootstrap', []))
35+
}
36+
},
3137
relay: {
3238
enabled: get(self._options, 'EXPERIMENTAL.relay.enabled',
3339
get(config, 'EXPERIMENTAL.relay.enabled', false)),
@@ -37,6 +43,10 @@ module.exports = function libp2p (self) {
3743
active: get(self._options, 'EXPERIMENTAL.relay.hop.active',
3844
get(config, 'EXPERIMENTAL.relay.hop.active', false))
3945
}
46+
},
47+
EXPERIMENTAL: {
48+
dht: get(self._options, 'EXPERIMENTAL.dht', false),
49+
pubsub: get(self._options, 'EXPERIMENTAL.pubsub', false)
4050
}
4151
}
4252
}

src/core/runtime/libp2p-browser.js

Lines changed: 43 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,38 +5,55 @@ const WebRTCStar = require('libp2p-webrtc-star')
55
const WebSocketStar = require('libp2p-websocket-star')
66
const Multiplex = require('libp2p-mplex')
77
const SECIO = require('libp2p-secio')
8-
const Railing = require('libp2p-railing')
8+
const Bootstrap = require('libp2p-railing')
99
const libp2p = require('libp2p')
10+
const defaultsDeep = require('lodash.defaultsdeep')
1011

1112
class Node extends libp2p {
12-
constructor (peerInfo, peerBook, options) {
13-
options = options || {}
14-
const wrtcstar = new WebRTCStar({id: peerInfo.id})
15-
const wsstar = new WebSocketStar({id: peerInfo.id})
16-
17-
const modules = {
18-
transport: [new WS(), wrtcstar, wsstar],
19-
connection: {
20-
muxer: [Multiplex],
21-
crypto: [SECIO]
13+
constructor (_options) {
14+
const wrtcstar = new WebRTCStar({id: _options.peerInfo.id})
15+
const wsstar = new WebSocketStar({id: _options.peerInfo.id})
16+
17+
const defaults = {
18+
modules: {
19+
transport: [
20+
WS,
21+
wrtcstar,
22+
wsstar
23+
],
24+
streamMuxer: [
25+
Multiplex
26+
],
27+
connEncryption: [
28+
SECIO
29+
],
30+
peerDiscovery: [
31+
wrtcstar.discovery,
32+
wsstar.discovery,
33+
Bootstrap
34+
]
2235
},
23-
discovery: [wrtcstar.discovery, wsstar.discovery]
24-
}
25-
26-
if (options.bootstrap) {
27-
const r = new Railing(options.bootstrap)
28-
modules.discovery.push(r)
29-
}
30-
31-
if (options.modules && options.modules.transport) {
32-
options.modules.transport.forEach((t) => modules.transport.push(t))
33-
}
34-
35-
if (options.modules && options.modules.discovery) {
36-
options.modules.discovery.forEach((d) => modules.discovery.push(d))
36+
config: {
37+
peerDiscovery: {
38+
bootstrap: {
39+
enabled: true
40+
},
41+
webRTCStar: {
42+
enabled: true
43+
},
44+
websocketStar: {
45+
enabled: true
46+
}
47+
},
48+
EXPERIMENTAL: {
49+
dht: false,
50+
pubsub: false
51+
}
52+
}
3753
}
3854

39-
super(modules, peerInfo, peerBook, options)
55+
defaultsDeep(_options, defaults)
56+
super(_options)
4057
}
4158
}
4259

src/core/runtime/libp2p-nodejs.js

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ const defaultsDeep = require('lodash.defaultsdeep')
1414
class Node extends libp2p {
1515
constructor (_options) {
1616
const wsstar = new WebSocketStar({id: _options.peerInfo.id})
17-
const mdns = new MulticastDNS(_options.peerInfo, 'ipfs.local')
1817

1918
const defaults = {
2019
modules: {
2120
transport: [
2221
TCP,
23-
WS
22+
WS,
23+
wsstar
2424
],
2525
streamMuxer: [
2626
Multiplex
@@ -30,36 +30,34 @@ class Node extends libp2p {
3030
],
3131
peerDiscovery: [
3232
MulticastDNS,
33-
Bootstrap
33+
Bootstrap,
34+
wsstar.discovery
3435
],
35-
peerRouting: [],
36-
contentRouting: [],
3736
dht: KadDHT
3837
},
3938
config: {
4039
peerDiscovery: {
40+
mdns: {
41+
enabled: true
42+
},
4143
bootstrap: {
42-
list: _options.bootstrapList
44+
enabled: true
45+
},
46+
websocketStar: {
47+
enabled: true
4348
}
4449
},
45-
peerRouting: {},
46-
contentRouting: {},
4750
dht: {
4851
kBucketSize: 20
52+
},
53+
EXPERIMENTAL: {
54+
dht: false,
55+
pubsub: false
4956
}
50-
},
51-
EXPERIMENTAL: {
52-
dht: false,
53-
pubsub: false
5457
}
5558
}
5659

5760
defaultsDeep(_options, defaults)
58-
59-
_options.modules.transport.push(wsstar)
60-
_options.modules.peerDiscovery.push(wsstar)
61-
_options.modules.peerDiscovery.push(mdns)
62-
6361
super(_options)
6462
}
6563
}

0 commit comments

Comments
 (0)