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

feat: bootstrap as an option #735

Merged
merged 1 commit into from
Jan 29, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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