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

Commit

Permalink
fix: actually expose block API
Browse files Browse the repository at this point in the history
  • Loading branch information
Alan Shaw committed Dec 11, 2019
1 parent 1b5c95e commit 070236c
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cli/commands/block/rm.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module.exports = {
const ipfs = await getIpfs()
let errored = false

for await (const result of ipfs.block._rmAsyncIterator(hash, {
for await (const result of ipfs.block.rm(hash, {
force,
quiet
})) {
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/block/get.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

const { cleanCid } = require('./utils')

module.exports = function block ({ blockService, preload }) {
module.exports = ({ blockService, preload }) => {
return async function get (cid, options) { // eslint-disable-line require-await
options = options || {}
cid = cleanCid(cid)
Expand Down
6 changes: 6 additions & 0 deletions src/core/components/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
'use strict'

exports.add = require('./add')
exports.block = {
get: require('./block/get'),
put: require('./block/put'),
rm: require('./block/rm'),
stat: require('./block/stat')
}
exports.config = require('./config')
exports.init = require('./init')
exports.pin = {
Expand Down
6 changes: 6 additions & 0 deletions src/core/components/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,12 @@ function createApi ({

const api = {
add,
block: {
get: Commands.block.get({ blockService, preload }),
put: Commands.block.put({ blockService, gcLock, preload }),
rm: Commands.block.rm({ blockService, gcLock, pinManager }),
stat: Commands.block.stat({ blockService, preload })
},
config: Commands.config({ repo }),
init: () => { throw new AlreadyInitializedError() },
pin,
Expand Down
6 changes: 6 additions & 0 deletions src/core/components/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,12 @@ function createApi ({

const api = {
add,
block: {
get: Commands.block.get({ blockService, preload }),
put: Commands.block.put({ blockService, gcLock, preload }),
rm: Commands.block.rm({ blockService, gcLock, pinManager }),
stat: Commands.block.stat({ blockService, preload })
},
config: Commands.config({ repo }),
init: () => { throw new AlreadyInitializedError() },
pin,
Expand Down
7 changes: 7 additions & 0 deletions src/core/components/stop.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,15 @@ function createApi ({

const api = {
add,
block: {
get: Commands.block.get({ blockService, preload }),
put: Commands.block.put({ blockService, gcLock, preload }),
rm: Commands.block.rm({ blockService, gcLock, pinManager }),
stat: Commands.block.stat({ blockService, preload })
},
config: Commands.config({ repo }),
init: () => { throw new AlreadyInitializedError() },
pin,
start,
stop: () => apiManager.api
}
Expand Down
2 changes: 1 addition & 1 deletion src/http/api/resources/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ exports.rm = {

return streamResponse(request, h, async (output) => {
try {
for await (const result of request.server.app.ipfs.block._rmAsyncIterator(arg, {
for await (const result of request.server.app.ipfs.block.rm(arg, {
force,
quiet
})) {
Expand Down

0 comments on commit 070236c

Please sign in to comment.