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

Commit

Permalink
feat: enable bootstrap to be an option
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias committed Jan 29, 2017
1 parent 990f1a7 commit 93a8d2e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
},
"dependencies": {
"libp2p": "^0.5.1",
"libp2p-railing": "^0.4.0",
"libp2p-secio": "^0.6.5",
"libp2p-spdy": "^0.10.3",
"libp2p-swarm": "^0.26.13",
Expand All @@ -61,4 +62,4 @@
"Richard Littauer <[email protected]>",
"greenkeeperio-bot <[email protected]>"
]
}
}
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ const WS = require('libp2p-websockets')
const WebRTCStar = require('libp2p-webrtc-star')
const spdy = require('libp2p-spdy')
const secio = require('libp2p-secio')
const Railing = require('libp2p-railing')
const libp2p = require('libp2p')

class Node extends libp2p {
constructor (peerInfo, peerBook, options) {
options = options || {}
const webRTCStar = new WebRTCStar()

const modules = {
Expand All @@ -27,6 +29,12 @@ class Node extends libp2p {
webRTCStar.discovery
]
}

if (options.bootstrap && process.env.IPFS_BOOTSTRAP) {
const r = new Railing(options.bootstrap)
modules.discovery.push(r)
}

super(modules, peerInfo, peerBook, options)
}
}
Expand Down

0 comments on commit 93a8d2e

Please sign in to comment.