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

Commit

Permalink
adapted to new ipfs-repo API
Browse files Browse the repository at this point in the history
  • Loading branch information
pgte committed Jun 30, 2017
1 parent fcef848 commit d188a66
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 31 deletions.
2 changes: 0 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@
"libp2p-ipfs-nodejs": "~0.25.2",
"lodash.flatmap": "^4.5.0",
"lodash.get": "^4.4.2",
"lodash.has": "^4.5.2",
"lodash.set": "^4.3.2",
"lodash.sortby": "^4.7.0",
"lodash.values": "^4.3.0",
"mafmt": "^2.1.8",
Expand Down
29 changes: 3 additions & 26 deletions src/core/components/config.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
'use strict'

const promisify = require('promisify-es6')
const _get = require('lodash.get')
const _has = require('lodash.has')
const _set = require('lodash.set')

module.exports = function config (self) {
return {
Expand All @@ -15,23 +12,9 @@ module.exports = function config (self) {

if (!key) {
return self._repo.config.get(callback)
} else {
return self._repo.config.get(key, callback)
}

if (typeof key !== 'string') {
return callback(new Error('Invalid key type'))
}

self._repo.config.get((err, config) => {
if (err) {
return callback(err)
}
if (_has(config, key)) {
const value = _get(config, key, undefined)
callback(null, value)
} else {
callback(new Error('Key does not exist in config'))
}
})
}),
set: promisify((key, value, callback) => {
if (!key || typeof key !== 'string') {
Expand All @@ -42,13 +25,7 @@ module.exports = function config (self) {
return callback(new Error('Invalid value type'))
}

self._repo.config.get((err, config) => {
if (err) {
return callback(err)
}
_set(config, key, value)
self.config.replace(config, callback)
})
self._repo.config.set(key, value, callback)
}),
replace: promisify((config, callback) => {
self._repo.config.set(config, callback)
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/dht.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ module.exports = (self) => {

// ensure blocks are actually local
every(keys, (key, cb) => {
self._repo.blockstore.has(key, cb)
self._repo.blocks.has(key, cb)
}, (err, has) => {
if (err) {
return callback(err)
Expand Down
2 changes: 1 addition & 1 deletion src/core/components/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ module.exports = (self) => {

self._bitswap = new Bitswap(
self._libp2pNode,
self._repo.blockstore,
self._repo.blocks,
self._peerInfoBook
)

Expand Down
2 changes: 1 addition & 1 deletion src/http-api/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ function HttpApi (repo, config) {
console.log('Gateway (readonly) is listening on: %s', gateway.info.ma)

// for the CLI to know the where abouts of the API
this.node._repo.setApiAddress(api.info.ma, cb)
this.node._repo.apiAddr.set(api.info.ma, cb)
}
], (err) => {
this.log('done', err)
Expand Down

0 comments on commit d188a66

Please sign in to comment.