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

Commit f6569ae

Browse files
pgtedryajov
authored andcommitted
feat: adapted to new ipfs-repo API (#887)
* feat: adapted to new ipfs-repo API
1 parent 954d8d1 commit f6569ae

File tree

6 files changed

+12
-49
lines changed

6 files changed

+12
-49
lines changed

package.json

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@
100100
"hapi-set-header": "^1.0.2",
101101
"hoek": "^4.1.1",
102102
"ipfs-api": "^14.0.4",
103-
"ipfs-bitswap": "~0.13.1",
103+
"ipfs-bitswap": "~0.14.0",
104104
"ipfs-block": "~0.6.0",
105-
"ipfs-block-service": "~0.9.1",
105+
"ipfs-block-service": "~0.10.0",
106106
"ipfs-multipart": "~0.1.0",
107-
"ipfs-repo": "~0.13.1",
107+
"ipfs-repo": "~0.15.0",
108108
"ipfs-unixfs": "~0.1.12",
109-
"ipfs-unixfs-engine": "~0.20.0",
110-
"ipld-resolver": "~0.11.1",
109+
"ipfs-unixfs-engine": "~0.21.0",
110+
"ipld-resolver": "~0.12.0",
111111
"is-ipfs": "^0.3.0",
112112
"isstream": "^0.1.2",
113113
"joi": "^10.6.0",
@@ -125,8 +125,6 @@
125125
"libp2p-websockets": "^0.10.0",
126126
"lodash.flatmap": "^4.5.0",
127127
"lodash.get": "^4.4.2",
128-
"lodash.has": "^4.5.2",
129-
"lodash.set": "^4.3.2",
130128
"lodash.sortby": "^4.7.0",
131129
"lodash.values": "^4.3.0",
132130
"mafmt": "^2.1.8",

src/core/components/config.js

Lines changed: 2 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
'use strict'
22

33
const promisify = require('promisify-es6')
4-
const _get = require('lodash.get')
5-
const _has = require('lodash.has')
6-
const _set = require('lodash.set')
74

85
module.exports = function config (self) {
96
return {
@@ -13,42 +10,10 @@ module.exports = function config (self) {
1310
key = undefined
1411
}
1512

16-
if (!key) {
17-
return self._repo.config.get(callback)
18-
}
19-
20-
if (typeof key !== 'string') {
21-
return callback(new Error('Invalid key type'))
22-
}
23-
24-
self._repo.config.get((err, config) => {
25-
if (err) {
26-
return callback(err)
27-
}
28-
if (_has(config, key)) {
29-
const value = _get(config, key, undefined)
30-
callback(null, value)
31-
} else {
32-
callback(new Error('Key does not exist in config'))
33-
}
34-
})
13+
return self._repo.config.get(key, callback)
3514
}),
3615
set: promisify((key, value, callback) => {
37-
if (!key || typeof key !== 'string') {
38-
return callback(new Error('Invalid key type'))
39-
}
40-
41-
if (value === undefined || Buffer.isBuffer(value)) {
42-
return callback(new Error('Invalid value type'))
43-
}
44-
45-
self._repo.config.get((err, config) => {
46-
if (err) {
47-
return callback(err)
48-
}
49-
_set(config, key, value)
50-
self.config.replace(config, callback)
51-
})
16+
self._repo.config.set(key, value, callback)
5217
}),
5318
replace: promisify((config, callback) => {
5419
self._repo.config.set(config, callback)

src/core/components/dht.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ module.exports = (self) => {
116116

117117
// ensure blocks are actually local
118118
every(keys, (key, cb) => {
119-
self._repo.blockstore.has(key, cb)
119+
self._repo.blocks.has(key, cb)
120120
}, (err, has) => {
121121
if (err) {
122122
return callback(err)

src/core/components/start.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ module.exports = (self) => {
4343

4444
self._bitswap = new Bitswap(
4545
self._libp2pNode,
46-
self._repo.blockstore,
46+
self._repo.blocks,
4747
self._peerInfoBook
4848
)
4949

5050
self._bitswap.start()
51-
self._blockService.goOnline(self._bitswap)
51+
self._blockService.setExchange(self._bitswap)
5252

5353
if (self._options.EXPERIMENTAL.pubsub) {
5454
self._pubsub = new FloodSub(self._libp2pNode)

src/core/components/stop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ module.exports = (self) => {
2626
}
2727

2828
self.state.stop()
29-
self._blockService.goOffline()
29+
self._blockService.unsetExchange()
3030
self._bitswap.stop()
3131

3232
series([

src/http-api/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ function HttpApi (repo, config) {
130130
console.log('Gateway (readonly) is listening on: %s', gateway.info.ma)
131131

132132
// for the CLI to know the where abouts of the API
133-
this.node._repo.setApiAddress(api.info.ma, cb)
133+
this.node._repo.apiAddr.set(api.info.ma, cb)
134134
}
135135
], (err) => {
136136
this.log('done', err)

0 commit comments

Comments
 (0)