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

[WIP] remove boot from constructor #1359

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 12 additions & 0 deletions src/core/components/boot.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict'

module.exports = (self) => () => {
return new Promise((resolve, reject) => {
/*
Refactor the `src/core/boot.js` in order to return a promise.
This way the error propagation will be made using promises/callbacks
and so, event emitters will not be necessary.
*/
resolve(self)
})
}
1 change: 1 addition & 0 deletions src/core/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ exports.version = require('./version')
exports.id = require('./id')
exports.repo = require('./repo')
exports.init = require('./init')
exports.boot = require('./boot')
exports.bootstrap = require('./bootstrap')
exports.config = require('./config')
exports.block = require('./block')
Expand Down
19 changes: 15 additions & 4 deletions src/core/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class IPFS extends EventEmitter {
this._options = {
init: true,
start: true,
boot: true,
EXPERIMENTAL: {}
}

Expand Down Expand Up @@ -88,6 +89,7 @@ class IPFS extends EventEmitter {
this.stop = components.stop(this)
this.shutdown = this.stop
this.isOnline = components.isOnline(this)
this.boot = components.boot(this)
// - interface-ipfs-core defined API
this.version = components.version(this)
this.id = components.id(this)
Expand Down Expand Up @@ -134,12 +136,21 @@ class IPFS extends EventEmitter {
isIPFS: isIPFS
}

boot(this)
if (this._options.boot) {
boot(this)
}
}
}

exports = module.exports = IPFS

exports.createNode = (options) => {
IPFS.createNode = (options) => {
return new IPFS(options)
}

IPFS.bootNewNode = (opts = {}) => {
const options = Object.assign(opts, { boot: false })
const node = new IPFS(options)

return node.boot()
}

module.exports = IPFS