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

Commit

Permalink
fix: stop api
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw committed Dec 16, 2019
1 parent efbe03a commit 5f4597a
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 60 deletions.
41 changes: 15 additions & 26 deletions src/core/components/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,26 +101,21 @@ module.exports = ({
morticeId: repo.path
})

<<<<<<< HEAD
const dag = Commands.legacy.dag({ _ipld: ipld, _preload: preload })
const dag = Components.legacy.dag({ _ipld: ipld, _preload: preload })
const object = {
data: Commands.object.data({ ipld, preload }),
get: Commands.object.get({ ipld, preload }),
links: Commands.object.links({ dag }),
new: Commands.object.new({ ipld, preload }),
data: Components.object.data({ ipld, preload }),
get: Components.object.get({ ipld, preload }),
links: Components.object.links({ dag }),
new: Components.object.new({ ipld, preload }),
patch: {
addLink: Commands.object.patch.addLink({ ipld, gcLock, preload }),
appendData: Commands.object.patch.appendData({ ipld, gcLock, preload }),
rmLink: Commands.object.patch.rmLink({ ipld, gcLock, preload }),
setData: Commands.object.patch.setData({ ipld, gcLock, preload })
addLink: Components.object.patch.addLink({ ipld, gcLock, preload }),
appendData: Components.object.patch.appendData({ ipld, gcLock, preload }),
rmLink: Components.object.patch.rmLink({ ipld, gcLock, preload }),
setData: Components.object.patch.setData({ ipld, gcLock, preload })
},
put: Commands.object.put({ ipld, gcLock, preload }),
stat: Commands.object.stat({ ipld, preload })
put: Components.object.put({ ipld, gcLock, preload }),
stat: Components.object.stat({ ipld, preload })
}
=======
const dag = Components.legacy.dag({ _ipld: ipld, _preload: preload })
const object = Components.legacy.object({ _ipld: ipld, _preload: preload, dag, _gcLock: gcLock })
>>>>>>> refactor: expose APIs

const pinManager = new PinManager(repo, dag)
await pinManager.load()
Expand Down Expand Up @@ -307,21 +302,15 @@ function createApi ({

const api = {
add,
<<<<<<< HEAD
config: Commands.config({ repo }),
id: Commands.id({ peerInfo }),
init: () => { throw new AlreadyInitializedError() },
object,
start,
version: Commands.version({ repo })
=======
cat: Components.cat({ ipld, preload }),
config: Components.config({ repo }),
dns: Components.dns(),
get: Components.get({ ipld, preload }),
id: Components.id({ peerInfo }),
init: () => { throw new AlreadyInitializedError() },
isOnline: Components.isOnline({}),
ls: Components.ls({ ipld, preload }),
object,
refs,
start: Components.start({
apiManager,
Expand All @@ -336,8 +325,8 @@ function createApi ({
preload,
print,
repo
})
>>>>>>> refactor: expose APIs
}),
version: Components.version({ repo })
}

return api
Expand Down
73 changes: 39 additions & 34 deletions src/core/components/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const defer = require('p-defer')
const { NotStartedError, AlreadyInitializedError } = require('../errors')
const Commands = require('./')
const Components = require('./')

module.exports = ({
apiManager,
Expand Down Expand Up @@ -76,48 +76,53 @@ function createApi ({
print,
repo
}) {
const dag = Commands.legacy.dag({ _ipld: ipld, _preload: preload })
const dag = Components.legacy.dag({ _ipld: ipld, _preload: preload })
const object = {
data: Commands.object.data({ ipld, preload }),
get: Commands.object.get({ ipld, preload }),
links: Commands.object.links({ dag }),
new: Commands.object.new({ ipld, preload }),
data: Components.object.data({ ipld, preload }),
get: Components.object.get({ ipld, preload }),
links: Components.object.links({ dag }),
new: Components.object.new({ ipld, preload }),
patch: {
addLink: Commands.object.patch.addLink({ ipld, gcLock, preload }),
appendData: Commands.object.patch.appendData({ ipld, gcLock, preload }),
rmLink: Commands.object.patch.rmLink({ ipld, gcLock, preload }),
setData: Commands.object.patch.setData({ ipld, gcLock, preload })
addLink: Components.object.patch.addLink({ ipld, gcLock, preload }),
appendData: Components.object.patch.appendData({ ipld, gcLock, preload }),
rmLink: Components.object.patch.rmLink({ ipld, gcLock, preload }),
setData: Components.object.patch.setData({ ipld, gcLock, preload })
},
put: Commands.object.put({ ipld, gcLock, preload }),
stat: Commands.object.stat({ ipld, preload })
put: Components.object.put({ ipld, gcLock, preload }),
stat: Components.object.stat({ ipld, preload })
}
const pin = Commands.legacy.pin({ _ipld: ipld, _preload: preload, object, _repo: repo, _pinManager: pinManager })
const add = Commands.add({ ipld, dag, preload, pin, gcLock, options: constructorOptions })

const start = Commands.start({
apiManager,
options: constructorOptions,
blockService,
gcLock,
initOptions,
ipld,
keychain,
object,
peerInfo,
pinManager,
preload,
print,
repo
})
const pin = Components.legacy.pin({ _ipld: ipld, _preload: preload, object, _repo: repo, _pinManager: pinManager })
const add = Components.add({ ipld, dag, preload, pin, gcLock, options: constructorOptions })
const refs = () => { throw new NotStartedError() }
refs.local = Components.refs.local({ repo })

const api = {
add,
config: Commands.config({ repo }),
id: Commands.id({ peerInfo }),
cat: Components.cat({ ipld, preload }),
config: Components.config({ repo }),
dns: Components.dns(),
get: Components.get({ ipld, preload }),
id: Components.id({ peerInfo }),
init: () => { throw new AlreadyInitializedError() },
start,
isOnline: Components.isOnline({}),
ls: Components.ls({ ipld, preload }),
refs,
start: Components.start({
apiManager,
options: constructorOptions,
blockService,
gcLock,
initOptions,
ipld,
keychain,
peerInfo,
pinManager,
preload,
print,
repo
}),
stop: () => apiManager.api,
version: Commands.version({ repo })
version: Components.version({ repo })
}

return api
Expand Down

0 comments on commit 5f4597a

Please sign in to comment.