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

Commit

Permalink
feat: bootstrap as an option (#735)
Browse files Browse the repository at this point in the history
  • Loading branch information
daviddias authored Jan 29, 2017
1 parent 7999b9d commit 03362a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ Commands:
- default repo location: `~/.jsipfs` (can be changed with env variable `IPFS_PATH`)
- default swarm port: `4002`
- default API port: `5002`
- default Bootstrap is off, to enable it set `IPFS_BOOTSTRAP=1`

### HTTP-API

Expand Down
9 changes: 8 additions & 1 deletion src/cli/commands/swarm/peers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

const utils = require('../../utils')
const debug = require('debug')
const mafmt = require('mafmt')
const multiaddr = require('multiaddr')
const log = debug('cli:object')
log.error = debug('cli:object:error')

Expand All @@ -28,7 +30,12 @@ module.exports = {
}

result.forEach((item) => {
console.log(item.addr.toString())
let ma = multiaddr(item.addr.toString())
if (!mafmt.IPFS.matches(ma)) {
ma = ma.encapsulate('/ipfs/' + item.peer.toB58String())
}
const addr = ma.toString()
console.log(addr)
})
})
})
Expand Down
9 changes: 6 additions & 3 deletions src/core/components/libp2p.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,17 @@ const promisify = require('promisify-es6')
module.exports = function libp2p (self) {
return {
start: promisify((callback) => {
self.config.get('Discovery.MDNS.Enabled', gotConfig)
self.config.get(gotConfig)

function gotConfig (err, enabled) {
function gotConfig (err, config) {
if (err) {
return callback(err)
}

const options = { mdns: enabled }
const options = {
mdns: config.Discovery.MDNS.Enabled,
bootstrap: config.Bootstrap
}

self._libp2pNode = new Node(self._peerInfo, undefined, options)

Expand Down

0 comments on commit 03362a3

Please sign in to comment.