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

Commit 03362a3

Browse files
authored
feat: bootstrap as an option (#735)
1 parent 7999b9d commit 03362a3

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ Commands:
183183
- default repo location: `~/.jsipfs` (can be changed with env variable `IPFS_PATH`)
184184
- default swarm port: `4002`
185185
- default API port: `5002`
186+
- default Bootstrap is off, to enable it set `IPFS_BOOTSTRAP=1`
186187

187188
### HTTP-API
188189

src/cli/commands/swarm/peers.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
const utils = require('../../utils')
44
const debug = require('debug')
5+
const mafmt = require('mafmt')
6+
const multiaddr = require('multiaddr')
57
const log = debug('cli:object')
68
log.error = debug('cli:object:error')
79

@@ -28,7 +30,12 @@ module.exports = {
2830
}
2931

3032
result.forEach((item) => {
31-
console.log(item.addr.toString())
33+
let ma = multiaddr(item.addr.toString())
34+
if (!mafmt.IPFS.matches(ma)) {
35+
ma = ma.encapsulate('/ipfs/' + item.peer.toB58String())
36+
}
37+
const addr = ma.toString()
38+
console.log(addr)
3239
})
3340
})
3441
})

src/core/components/libp2p.js

+6-3
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ const promisify = require('promisify-es6')
66
module.exports = function libp2p (self) {
77
return {
88
start: promisify((callback) => {
9-
self.config.get('Discovery.MDNS.Enabled', gotConfig)
9+
self.config.get(gotConfig)
1010

11-
function gotConfig (err, enabled) {
11+
function gotConfig (err, config) {
1212
if (err) {
1313
return callback(err)
1414
}
1515

16-
const options = { mdns: enabled }
16+
const options = {
17+
mdns: config.Discovery.MDNS.Enabled,
18+
bootstrap: config.Bootstrap
19+
}
1720

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

0 commit comments

Comments
 (0)