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

Commit

Permalink
chore: apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-Authored-By: dirkmc <dirkmdev@gmail.com>
  • Loading branch information
vasco-santos and dirkmc committed Jun 28, 2019
1 parent e378ea9 commit 02d65c7
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
18 changes: 12 additions & 6 deletions src/core/components/start.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use strict'

const get = require('dlv')
const callbackify = require('callbackify')
const series = require('async/series')
const Bitswap = require('ipfs-bitswap')
const setImmediate = require('async/setImmediate')
Expand Down Expand Up @@ -48,8 +49,18 @@ module.exports = (self) => {
if (err) return cb(err)
self.libp2p = libp2p

// create provider
self._provider = new Provider(libp2p, self._repo.blocks, get(config, 'Reprovider'))
cb()

// start provider if libp2p routing enabled
if (!get(self._options, 'offline') &&
(get(self._options, 'libp2p.config.dht.enabled', false) || get(self._options, 'libp2p.modules.contentRouting', false))) {
const providerStart = callbackify(() => self._provider.start())

providerStart(cb)
} else {
cb()
}
})
})
},
Expand All @@ -64,11 +75,6 @@ module.exports = (self) => {
{ statsEnabled: true }
)

if (!get(self._options, 'offline') &&
(get(self._options, 'libp2p.config.dht.enabled', false) || get(self._options, 'libp2p.modules.contentRouting', false))) {
self._provider.start()
}

self._bitswap.start()
self._blockService.setExchange(self._bitswap)

Expand Down
2 changes: 1 addition & 1 deletion src/core/provider/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Provider {
* @returns {void}
*/
stop () {
this._running = true
this._running = false

// stop the reprovider
this.reprovider.stop()
Expand Down
4 changes: 2 additions & 2 deletions src/core/provider/reprovider.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class Reprovider {
* @param {object} contentRouting
* @param {Blockstore} blockstore
* @param {object} options
* @param {string} options.delay reprovider initial delay in human friendly time
* @param {string} options.interval reprovider interval in human friendly time
* @param {string} options.delay reprovider initial delay in milliseconds
* @param {string} options.interval reprovider interval in milliseconds
* @param {string} options.strategy reprovider strategy
*/
constructor (contentRouting, blockstore, options) {
Expand Down

0 comments on commit 02d65c7

Please sign in to comment.