Skip to content
This repository was archived by the owner on Apr 29, 2020. It is now read-only.

Commit 93a8d2e

Browse files
committed
feat: enable bootstrap to be an option
1 parent 990f1a7 commit 93a8d2e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
},
4545
"dependencies": {
4646
"libp2p": "^0.5.1",
47+
"libp2p-railing": "^0.4.0",
4748
"libp2p-secio": "^0.6.5",
4849
"libp2p-spdy": "^0.10.3",
4950
"libp2p-swarm": "^0.26.13",
@@ -61,4 +62,4 @@
6162
"Richard Littauer <[email protected]>",
6263
"greenkeeperio-bot <[email protected]>"
6364
]
64-
}
65+
}

src/index.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ const WS = require('libp2p-websockets')
44
const WebRTCStar = require('libp2p-webrtc-star')
55
const spdy = require('libp2p-spdy')
66
const secio = require('libp2p-secio')
7+
const Railing = require('libp2p-railing')
78
const libp2p = require('libp2p')
89

910
class Node extends libp2p {
1011
constructor (peerInfo, peerBook, options) {
12+
options = options || {}
1113
const webRTCStar = new WebRTCStar()
1214

1315
const modules = {
@@ -27,6 +29,12 @@ class Node extends libp2p {
2729
webRTCStar.discovery
2830
]
2931
}
32+
33+
if (options.bootstrap && process.env.IPFS_BOOTSTRAP) {
34+
const r = new Railing(options.bootstrap)
35+
modules.discovery.push(r)
36+
}
37+
3038
super(modules, peerInfo, peerBook, options)
3139
}
3240
}

0 commit comments

Comments
 (0)