Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'use strict'
const RepoErrors = require('ipfs-repo').errors
// Boot an IPFS node depending on the options set
module.exports = async (self) => {
self.log('booting')
const options = self._options
const doInit = options.init
const doStart = options.start
// Checks if a repo exists, and if so opens it
// Will return callback with a bool indicating the existence
// of the repo
async function repoOpened () {
// nothing to do
if (!self._repo.closed) {
return true
}
const NoKeychain = require('../components/no-keychain')
const GCLock = require('../components/pin/gc-lock')
const { DAGNode } = require('ipld-dag-pb')
const UnixFs = require('ipfs-unixfs')
const multicodec = require('multicodec')
const multiaddr = require('multiaddr')
const {
AlreadyInitializingError,
AlreadyInitializedError,
NotStartedError
} = require('../../errors')
const BlockService = require('ipfs-block-service')
const Ipld = require('ipld')
const getDefaultIpldOptions = require('../runtime/ipld-nodejs')
const createPreloader = require('./preload')
const { ERR_REPO_NOT_INITIALIZED } = require('ipfs-repo').errors
const IPNS = require('../ipns')
const OfflineDatastore = require('../ipns/routing/offline-datastore')
const initAssets = require('../runtime/init-assets-nodejs')
const Components = require('.')
const PinManager = require('../components/pin/pin-manager')
module.exports = ({
apiManager,
print,
constructorOptions
}) => async function init (options) {
const { cancel } = apiManager.update({ init: () => { throw new AlreadyInitializingError() } })
try {
options = mergeOptions({}, options, constructorOptions.init)