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

Commit f8862bc

Browse files
vmxachingbrain
authored andcommitted
Upgrade to the latest libp2p, ipfs-repo, ipfs-unixfs-*, ipfs-mfs, ipld-* (#2390)
* chore: bump dependencies for ipfs-repo async update * tests: update ipfsd-ctl This new version of ipfsd-ctl is using async/await instead of callbacks. Hence some rather mechanical changes are needed for tests. * feat: use async/await based ipfs-repo * chore: convert internals to promises * chore: update bundle size
1 parent 04a09b8 commit f8862bc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+2453
-2885
lines changed

.aegir.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const preloadNode = MockPreloadNode.createNode()
1010
const echoServer = EchoServer.createServer()
1111

1212
module.exports = {
13-
bundlesize: { maxSize: '696kB' },
13+
bundlesize: { maxSize: '685kB' },
1414
webpack: {
1515
resolve: {
1616
mainFields: ['browser', 'main'],

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,13 @@ env:
2828
# https://travis-ci.community/t/timeout-after-build-finished-and-succeeded/1336
2929
- YARN_GPG=no
3030

31+
addons:
32+
apt:
33+
packages:
34+
# Fixes error while loading shared libraries: libgconf-2.so.4: cannot open shared object file: No such file or directory
35+
# https://github.com/electron/electron/issues/1518
36+
- libgconf-2-4
37+
3138
script: npx nyc -s npx aegir test -t node --timeout 10000 --bail
3239
after_success:
3340
- npx nyc report --reporter=text-lcov > coverage.lcov && npx codecov

examples/traverse-ipld-graphs/create-node.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ const IPFS = require('../../src/core')
44
// In your project, replace by the following line and install IPFS as a dep
55
// const IPFS = require('ipfs')
66

7-
function createNode (options = {}) {
7+
function createNode (options) {
8+
options = options || {}
89
options.path = options.path || '/tmp/ipfs' + Math.random()
910
return IPFS.create({ repo: options.path })
1011
}

examples/traverse-ipld-graphs/eth.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const multihashing = require('multihashing-async')
66
const Block = require('ipfs-block')
77
const CID = require('cids')
88
const fs = require('fs').promises
9-
const { promisify } = require('util')
109

1110
async function main () {
1211
const ipfs = await createNode()
@@ -20,7 +19,7 @@ async function main () {
2019

2120
for (const ethBlockPath of ethBlocks) {
2221
const data = await fs.readFile(ethBlockPath)
23-
const multihash = await promisify(multihashing)(data, 'keccak-256')
22+
const multihash = await multihashing(data, 'keccak-256')
2423

2524
const cid = new CID(1, 'eth-block', multihash)
2625
// console.log(cid.toBaseEncodedString())

examples/traverse-ipld-graphs/get-path-accross-formats.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
'use strict'
22

33
const createNode = require('./create-node')
4-
const dagPB = require('ipld-dag-pb')
4+
const {
5+
DAGNode
6+
} = require('ipld-dag-pb')
57

68
async function main () {
79
const ipfs = await createNode()
810

911
console.log('\nStart of the example:')
1012

1113
const someData = Buffer.from('capoeira')
12-
const pbNode = dagPB.DAGNode.create(someData)
14+
const pbNode = new DAGNode(someData)
1315

1416
const pbNodeCid = await ipfs.dag.put(pbNode, {
1517
format: 'dag-pb',

examples/traverse-ipld-graphs/git.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ const multihashing = require('multihashing-async')
66
const Block = require('ipfs-block')
77
const CID = require('cids')
88
const fs = require('fs').promises
9-
const { promisify } = require('util')
109

1110
async function main () {
1211
const ipfs = await createNode()
@@ -28,7 +27,7 @@ async function main () {
2827

2928
await Promise.all(gitObjects.map(async gitObjectsPath => {
3029
const data = await fs.readFile(gitObjectsPath)
31-
const multihash = await promisify(multihashing)(data, 'sha1')
30+
const multihash = await multihashing(data, 'sha1')
3231

3332
const cid = new CID(1, 'git-raw', multihash)
3433
console.log(cid.toString())

examples/traverse-ipld-graphs/tree.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
11
'use strict'
22

33
const createNode = require('./create-node')
4-
const dagPB = require('ipld-dag-pb')
4+
const {
5+
DAGNode
6+
} = require('ipld-dag-pb')
57

68
async function main () {
79
const ipfs = await createNode()
810

911
console.log('\nStart of the example:')
1012

1113
const someData = Buffer.from('capoeira')
12-
const pbNode = dagPB.DAGNode.create(someData)
14+
const pbNode = new DAGNode(someData)
1315

1416
const pbNodeCid = await ipfs.dag.put(pbNode, {
1517
format: 'dag-pb',

package.json

+34-29
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@
6363
"@hapi/ammo": "^3.1.1",
6464
"@hapi/boom": "^7.4.3",
6565
"@hapi/hapi": "^18.3.2",
66-
"@hapi/joi": "^15.0.1",
66+
"@hapi/joi": "^15.0.0",
6767
"array-shuffle": "^1.0.1",
6868
"async": "^2.6.1",
6969
"async-iterator-all": "^1.0.0",
@@ -76,11 +76,13 @@
7676
"bs58": "^4.0.1",
7777
"buffer-peek-stream": "^1.0.1",
7878
"byteman": "^1.3.5",
79+
"callbackify": "^1.1.0",
7980
"cid-tool": "~0.3.0",
8081
"cids": "~0.7.1",
8182
"class-is": "^1.1.0",
82-
"datastore-core": "~0.6.0",
83-
"datastore-pubsub": "~0.1.1",
83+
"dag-cbor-links": "^1.3.0",
84+
"datastore-core": "~0.7.0",
85+
"datastore-pubsub": "^0.2.1",
8486
"debug": "^4.1.0",
8587
"dlv": "^1.1.3",
8688
"err-code": "^2.0.0",
@@ -93,28 +95,28 @@
9395
"hapi-pino": "^6.1.0",
9496
"hashlru": "^2.3.0",
9597
"human-to-milliseconds": "^2.0.0",
96-
"interface-datastore": "~0.6.0",
97-
"ipfs-bitswap": "~0.25.1",
98+
"interface-datastore": "~0.7.0",
99+
"ipfs-bitswap": "^0.26.0",
98100
"ipfs-block": "~0.8.1",
99-
"ipfs-block-service": "~0.15.2",
100-
"ipfs-http-client": "^37.0.2",
101+
"ipfs-block-service": "~0.16.0",
102+
"ipfs-http-client": "^38.0.0",
101103
"ipfs-http-response": "~0.3.1",
102-
"ipfs-mfs": "^0.12.2",
104+
"ipfs-mfs": "^0.13.0",
103105
"ipfs-multipart": "^0.2.0",
104-
"ipfs-repo": "~0.26.6",
106+
"ipfs-repo": "^0.28.0",
105107
"ipfs-unixfs": "~0.1.16",
106-
"ipfs-unixfs-exporter": "~0.37.7",
107-
"ipfs-unixfs-importer": "~0.39.11",
108+
"ipfs-unixfs-exporter": "^0.38.0",
109+
"ipfs-unixfs-importer": "^0.40.0",
108110
"ipfs-utils": "~0.4.0",
109-
"ipld": "~0.24.1",
111+
"ipld": "~0.25.0",
110112
"ipld-bitcoin": "~0.3.0",
111113
"ipld-dag-cbor": "~0.15.0",
112-
"ipld-dag-pb": "~0.17.4",
114+
"ipld-dag-pb": "~0.18.0",
113115
"ipld-ethereum": "^4.0.0",
114116
"ipld-git": "~0.5.0",
115117
"ipld-raw": "^4.0.0",
116118
"ipld-zcash": "~0.3.0",
117-
"ipns": "~0.5.2",
119+
"ipns": "^0.6.1",
118120
"is-domain-name": "^1.0.1",
119121
"is-ipfs": "~0.6.1",
120122
"is-pull-stream": "~0.0.0",
@@ -124,40 +126,43 @@
124126
"it-to-stream": "^0.1.1",
125127
"just-safe-set": "^2.1.0",
126128
"kind-of": "^6.0.2",
127-
"ky": "~0.14.0",
129+
"ky": "^0.14.0",
128130
"ky-universal": "~0.3.0",
129-
"libp2p": "~0.26.1",
131+
"libp2p": "^0.26.2",
130132
"libp2p-bootstrap": "~0.9.3",
131-
"libp2p-crypto": "~0.16.0",
132-
"libp2p-delegated-content-routing": "^0.2.4",
133-
"libp2p-delegated-peer-routing": "^0.2.4",
133+
"libp2p-crypto": "^0.16.2",
134+
"libp2p-delegated-content-routing": "^0.3.1",
135+
"libp2p-delegated-peer-routing": "^0.3.1",
134136
"libp2p-floodsub": "^0.18.0",
135137
"libp2p-gossipsub": "~0.0.5",
136-
"libp2p-kad-dht": "~0.15.3",
137-
"libp2p-keychain": "~0.4.2",
138+
"libp2p-kad-dht": "~0.16.0",
139+
"libp2p-keychain": "^0.5.1",
138140
"libp2p-mdns": "~0.12.0",
139-
"libp2p-record": "~0.6.3",
141+
"libp2p-record": "~0.7.0",
140142
"libp2p-secio": "~0.11.0",
141-
"libp2p-tcp": "~0.13.1",
143+
"libp2p-tcp": "^0.13.0",
142144
"libp2p-webrtc-star": "~0.16.0",
143145
"libp2p-websocket-star-multi": "~0.4.3",
144146
"libp2p-websockets": "~0.12.3",
145147
"lodash": "^4.17.15",
148+
"lodash.flatten": "^4.4.0",
146149
"mafmt": "^6.0.10",
147150
"merge-options": "^1.0.1",
148151
"mime-types": "^2.1.21",
149152
"mkdirp": "~0.5.1",
150153
"mortice": "^2.0.0",
151-
"multiaddr": "^6.1.0",
154+
"multiaddr": "^6.1.1",
152155
"multiaddr-to-uri": "^5.0.0",
153156
"multibase": "~0.6.0",
154157
"multicodec": "~0.5.5",
155158
"multihashes": "~0.4.14",
156-
"multihashing-async": "~0.6.0",
159+
"multihashing-async": "^0.8.0",
160+
"node-fetch": "^2.3.0",
161+
"p-iteration": "^1.1.8",
157162
"p-queue": "^6.1.0",
158-
"peer-book": "~0.9.0",
159-
"peer-id": "~0.12.3",
160-
"peer-info": "~0.15.0",
163+
"peer-book": "^0.9.1",
164+
"peer-id": "^0.12.2",
165+
"peer-info": "~0.15.1",
161166
"progress": "^2.0.1",
162167
"promise-nodeify": "^3.0.1",
163168
"promisify-es6": "^1.0.3",
@@ -199,7 +204,7 @@
199204
"execa": "^2.0.4",
200205
"form-data": "^2.5.1",
201206
"hat": "0.0.3",
202-
"interface-ipfs-core": "~0.114.0",
207+
"interface-ipfs-core": "^0.115.0",
203208
"ipfs-interop": "~0.1.0",
204209
"ipfsd-ctl": "^0.47.2",
205210
"libp2p-websocket-star": "~0.10.2",

src/cli/daemon.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ const TCP = require('libp2p-tcp')
99
const MulticastDNS = require('libp2p-mdns')
1010
const WS = require('libp2p-websockets')
1111
const Bootstrap = require('libp2p-bootstrap')
12-
const promisify = require('promisify-es6')
1312

1413
class Daemon {
1514
constructor (options) {
@@ -75,7 +74,7 @@ class Daemon {
7574

7675
// for the CLI to know the where abouts of the API
7776
if (this._httpApi._apiServers.length) {
78-
await promisify(ipfs._repo.apiAddr.set)(this._httpApi._apiServers[0].info.ma)
77+
await ipfs._repo.apiAddr.set(this._httpApi._apiServers[0].info.ma)
7978
}
8079

8180
this._log('started')

src/cli/utils.js

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ log.error = debug('cli:error')
1010
const Progress = require('progress')
1111
const byteman = require('byteman')
1212
const promisify = require('promisify-es6')
13+
const callbackify = require('callbackify')
1314

1415
exports.isDaemonOn = isDaemonOn
1516
function isDaemonOn () {
@@ -52,11 +53,9 @@ exports.getIPFS = (argv, callback) => {
5253
pass: argv.pass
5354
})
5455

55-
const cleanup = promisify((cb) => {
56+
const cleanup = callbackify(async () => {
5657
if (node && node._repo && !node._repo.closed) {
57-
node._repo.close((err) => cb(err))
58-
} else {
59-
cb()
58+
await node._repo.close()
6059
}
6160
})
6261

0 commit comments

Comments
 (0)