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

Commit 72b39a7

Browse files
daviddiasdryajov
authored andcommitted
fix: issue #905 (#906)
1 parent 4668862 commit 72b39a7

File tree

5 files changed

+14
-217
lines changed

5 files changed

+14
-217
lines changed

examples/transfer-files/package-lock.json

-137
This file was deleted.

examples/transfer-files/public/js/app.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,7 @@ function start () {
3232
if (!node) {
3333
updateView('starting', node)
3434

35-
node = new self.Ipfs({
36-
repo: 'ipfs-' + Math.random()
37-
})
35+
node = new self.Ipfs({repo: 'ipfs-' + Math.random()})
3836

3937
node.on('start', () => {
4038
node.id().then((id) => {

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"main": "src/core/index.js",
99
"browser": {
1010
"./src/core/components/init-assets.js": false,
11-
"./src/core/runtime/config-nodejs.js": "./src/core/runtime/config-browser.js",
11+
"./src/core/runtime/config-nodejs.json": "./src/core/runtime/config-browser.json",
1212
"./src/core/runtime/libp2p-nodejs.js": "./src/core/runtime/libp2p-browser.js",
1313
"./src/core/runtime/repo-nodejs.js": "./src/core/runtime/repo-browser.js",
1414
"./test/utils/create-repo-nodejs.js": "./test/utils/create-repo-browser.js",
@@ -118,7 +118,6 @@
118118
"libp2p-multiplex": "^0.4.3",
119119
"libp2p-railing": "^0.5.1",
120120
"libp2p-secio": "^0.6.8",
121-
"libp2p-spdy": "^0.10.6",
122121
"libp2p-swarm": "^0.29.1",
123122
"libp2p-tcp": "^0.10.1",
124123
"libp2p-webrtc-star": "^0.11.0",

src/core/runtime/libp2p-browser.js

+7-41
Original file line numberDiff line numberDiff line change
@@ -2,57 +2,23 @@
22

33
const WS = require('libp2p-websockets')
44
const WebRTCStar = require('libp2p-webrtc-star')
5-
const spdy = require('libp2p-spdy')
6-
const multiplex = require('libp2p-multiplex')
7-
const secio = require('libp2p-secio')
5+
const Multiplex = require('libp2p-multiplex')
6+
const SECIO = require('libp2p-secio')
87
const Railing = require('libp2p-railing')
98
const libp2p = require('libp2p')
109

11-
function mapMuxers (list) {
12-
return list.map((pref) => {
13-
if (typeof pref !== 'string') {
14-
return pref
15-
}
16-
switch (pref.trim().toLowerCase()) {
17-
case 'spdy':
18-
return spdy
19-
case 'multiplex':
20-
return multiplex
21-
default:
22-
throw new Error(pref + ' muxer not available')
23-
}
24-
})
25-
}
26-
27-
function getMuxers (options) {
28-
if (options) {
29-
return mapMuxers(options)
30-
} else {
31-
return [multiplex, spdy]
32-
}
33-
}
34-
3510
class Node extends libp2p {
3611
constructor (peerInfo, peerBook, options) {
3712
options = options || {}
38-
const webRTCStar = new WebRTCStar()
13+
const wstar = new WebRTCStar()
3914

4015
const modules = {
41-
transport: [
42-
new WS(),
43-
webRTCStar
44-
],
16+
transport: [new WS(), wstar],
4517
connection: {
46-
muxer: getMuxers(options.muxer),
47-
crypto: [
48-
secio
49-
]
18+
muxer: [Multiplex],
19+
crypto: [SECIO]
5020
},
51-
discovery: []
52-
}
53-
54-
if (options.webRTCStar) {
55-
modules.discovery.push(webRTCStar.discovery)
21+
discovery: [wstar.discovery]
5622
}
5723

5824
if (options.bootstrap) {

src/core/runtime/libp2p-nodejs.js

+5-34
Original file line numberDiff line numberDiff line change
@@ -4,49 +4,20 @@ const TCP = require('libp2p-tcp')
44
const MulticastDNS = require('libp2p-mdns')
55
const WS = require('libp2p-websockets')
66
const Railing = require('libp2p-railing')
7-
const spdy = require('libp2p-spdy')
87
const KadDHT = require('libp2p-kad-dht')
9-
const multiplex = require('libp2p-multiplex')
10-
const secio = require('libp2p-secio')
8+
const Multiplex = require('libp2p-multiplex')
9+
const SECIO = require('libp2p-secio')
1110
const libp2p = require('libp2p')
1211

13-
function mapMuxers (list) {
14-
return list.map((pref) => {
15-
if (typeof pref !== 'string') {
16-
return pref
17-
}
18-
switch (pref.trim().toLowerCase()) {
19-
case 'spdy': return spdy
20-
case 'multiplex': return multiplex
21-
default:
22-
throw new Error(pref + ' muxer not available')
23-
}
24-
})
25-
}
26-
27-
function getMuxers (muxers) {
28-
const muxerPrefs = process.env.LIBP2P_MUXER
29-
if (muxerPrefs && !muxers) {
30-
return mapMuxers(muxerPrefs.split(','))
31-
} else if (muxers) {
32-
return mapMuxers(muxers)
33-
} else {
34-
return [multiplex, spdy]
35-
}
36-
}
37-
3812
class Node extends libp2p {
3913
constructor (peerInfo, peerBook, options) {
4014
options = options || {}
4115

4216
const modules = {
43-
transport: [
44-
new TCP(),
45-
new WS()
46-
],
17+
transport: [new TCP(), new WS()],
4718
connection: {
48-
muxer: getMuxers(options.muxer),
49-
crypto: [ secio ]
19+
muxer: [Multiplex],
20+
crypto: [SECIO]
5021
},
5122
discovery: []
5223
}

0 commit comments

Comments
 (0)