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

Commit 02d65c7

Browse files
vasco-santosdirkmc
andcommitted
chore: apply suggestions from code review
Co-Authored-By: dirkmc <[email protected]>
1 parent e378ea9 commit 02d65c7

File tree

3 files changed

+15
-9
lines changed

3 files changed

+15
-9
lines changed

src/core/components/start.js

+12-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
'use strict'
22

33
const get = require('dlv')
4+
const callbackify = require('callbackify')
45
const series = require('async/series')
56
const Bitswap = require('ipfs-bitswap')
67
const setImmediate = require('async/setImmediate')
@@ -48,8 +49,18 @@ module.exports = (self) => {
4849
if (err) return cb(err)
4950
self.libp2p = libp2p
5051

52+
// create provider
5153
self._provider = new Provider(libp2p, self._repo.blocks, get(config, 'Reprovider'))
52-
cb()
54+
55+
// start provider if libp2p routing enabled
56+
if (!get(self._options, 'offline') &&
57+
(get(self._options, 'libp2p.config.dht.enabled', false) || get(self._options, 'libp2p.modules.contentRouting', false))) {
58+
const providerStart = callbackify(() => self._provider.start())
59+
60+
providerStart(cb)
61+
} else {
62+
cb()
63+
}
5364
})
5465
})
5566
},
@@ -64,11 +75,6 @@ module.exports = (self) => {
6475
{ statsEnabled: true }
6576
)
6677

67-
if (!get(self._options, 'offline') &&
68-
(get(self._options, 'libp2p.config.dht.enabled', false) || get(self._options, 'libp2p.modules.contentRouting', false))) {
69-
self._provider.start()
70-
}
71-
7278
self._bitswap.start()
7379
self._blockService.setExchange(self._bitswap)
7480

src/core/provider/index.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class Provider {
6363
* @returns {void}
6464
*/
6565
stop () {
66-
this._running = true
66+
this._running = false
6767

6868
// stop the reprovider
6969
this.reprovider.stop()

src/core/provider/reprovider.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ class Reprovider {
1111
* @param {object} contentRouting
1212
* @param {Blockstore} blockstore
1313
* @param {object} options
14-
* @param {string} options.delay reprovider initial delay in human friendly time
15-
* @param {string} options.interval reprovider interval in human friendly time
14+
* @param {string} options.delay reprovider initial delay in milliseconds
15+
* @param {string} options.interval reprovider interval in milliseconds
1616
* @param {string} options.strategy reprovider strategy
1717
*/
1818
constructor (contentRouting, blockstore, options) {

0 commit comments

Comments
 (0)