From 4c14a56d8df9da6797845214a594a1e1dda9f094 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 6 Feb 2019 09:46:04 +0000 Subject: [PATCH 01/16] refactor: encode using CID v1 base32 by default License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- src/core/components/files-regular/add-pull-stream.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 46aeb90ec1..9acce31081 100644 --- a/package.json +++ b/package.json @@ -90,7 +90,7 @@ "bs58": "^4.0.1", "byteman": "^1.3.5", "cid-tool": "~0.2.0", - "cids": "~0.5.5", + "cids": "github:ipld/js-cid#refactor/cidv1base32-default", "class-is": "^1.1.0", "datastore-core": "~0.6.0", "datastore-pubsub": "~0.1.1", diff --git a/src/core/components/files-regular/add-pull-stream.js b/src/core/components/files-regular/add-pull-stream.js index 0d56b5e459..90ebfe373f 100644 --- a/src/core/components/files-regular/add-pull-stream.js +++ b/src/core/components/files-regular/add-pull-stream.js @@ -27,7 +27,7 @@ function prepareFile (file, self, opts, callback) { ? cb(null, file) : self.object.get(file.multihash, Object.assign({}, opts, { preload: false }), cb), (node, cb) => { - const b58Hash = cid.toBaseEncodedString() + const cidStr = cid.toBaseEncodedString() let size = node.size @@ -38,8 +38,8 @@ function prepareFile (file, self, opts, callback) { cb(null, { path: opts.wrapWithDirectory ? file.path.substring(WRAPPER.length) - : (file.path || b58Hash), - hash: b58Hash, + : (file.path || cidStr), + hash: cidStr, size }) } From a5635b9e699cbef1ea9866a5db667152306ab4de Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 7 Feb 2019 08:59:25 +0000 Subject: [PATCH 02/16] chore: update ipfs-unixfs-engine dependency License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 9acce31081..66c8ad7bcc 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,7 @@ "ipfs-multipart": "~0.1.0", "ipfs-repo": "~0.26.1", "ipfs-unixfs": "~0.1.16", - "ipfs-unixfs-engine": "~0.35.3", + "ipfs-unixfs-engine": "github:ipfs/js-ipfs-unixfs-engine#refactor/cidv1b32-default", "ipld": "~0.21.1", "ipld-bitcoin": "~0.1.8", "ipld-dag-pb": "~0.15.0", From 798a33f6d01aa395bd48403774b1a29cac1bf527 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 7 Feb 2019 13:12:15 +0000 Subject: [PATCH 03/16] chore: update ipfs-mfs dependency License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 66c8ad7bcc..1f460dfc07 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "ipfs-block-service": "~0.15.1", "ipfs-http-client": "^29.0.0", "ipfs-http-response": "~0.2.1", - "ipfs-mfs": "~0.9.1", + "ipfs-mfs": "github:ipfs/js-ipfs-mfs#refactor/cidv1b32-default", "ipfs-multipart": "~0.1.0", "ipfs-repo": "~0.26.1", "ipfs-unixfs": "~0.1.16", From 593cafa8269dc86ee9148eb7104a614bca92d8c0 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 7 Feb 2019 15:06:20 +0000 Subject: [PATCH 04/16] test: unskip object tests License: MIT Signed-off-by: Alan Shaw --- test/cli/object.js | 18 ++++++------------ test/http-api/inject/object.js | 27 +++++++++------------------ 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/test/cli/object.js b/test/cli/object.js index ceb9f24627..10684aef25 100644 --- a/test/cli/object.js +++ b/test/cli/object.js @@ -34,8 +34,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should new and print CID encoded in specified base', () => { + it('should new and print CID encoded in specified base', () => { return ipfs('object new --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIOOwxEKY/BwUmvv0yJlvuSQnrkHkZJuTTKSVmRt4UrhV\n' @@ -103,8 +102,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should put and print CID encoded in specified base', () => { + it('should put and print CID encoded in specified base', () => { return ipfs('object put test/fixtures/test-data/node.json --cid-base=base64') .then((out) => { expect(out).to.eql( @@ -188,8 +186,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should append-data and print CID encoded in specified base', () => { + it('should append-data and print CID encoded in specified base', () => { return ipfs('object patch append-data QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n test/fixtures/test-data/badconfig --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIP+BZ7jGtaTyLGOs0xYcQvH7K9kVKEbyzXAkwLoZwrRj\n' @@ -205,8 +202,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should set-data and print CID encoded in specified base', () => { + it('should set-data and print CID encoded in specified base', () => { return ipfs('object patch set-data QmfY37rjbPCZRnhvvJuQ46htW3VCAWziVB991P79h6WSv6 test/fixtures/test-data/badconfig --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIP+BZ7jGtaTyLGOs0xYcQvH7K9kVKEbyzXAkwLoZwrRj\n' @@ -222,8 +218,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should add-link and print CID encoded in specified base', () => { + it('should add-link and print CID encoded in specified base', () => { return ipfs('object patch add-link QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n foo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIOEVPbXq2xYoEsRZhaPB61btcy1x359osjv4a2L/lgPs\n' @@ -239,8 +234,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should rm-link and print CID encoded in specified base', () => { + it('should rm-link and print CID encoded in specified base', () => { return ipfs('object patch rm-link QmdVHE8fUD6FLNLugtNxqDFyhaCgdob372hs6BYEe75VAK foo --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIOOwxEKY/BwUmvv0yJlvuSQnrkHkZJuTTKSVmRt4UrhV\n' diff --git a/test/http-api/inject/object.js b/test/http-api/inject/object.js index e329e98c64..13c5de8766 100644 --- a/test/http-api/inject/object.js +++ b/test/http-api/inject/object.js @@ -33,8 +33,7 @@ module.exports = (http) => { expect(res.result.Links).to.be.eql([]) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should create a new object and return a base64 encoded CID', async () => { + it('should create a new object and return a base64 encoded CID', async () => { const res = await api.inject({ method: 'POST', url: '/api/v0/object/new?cid-base=base64' @@ -88,8 +87,7 @@ module.exports = (http) => { expect(res.result.Data).to.be.empty() }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should get object and return a base64 encoded CID', async () => { + it('should get object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -185,8 +183,7 @@ module.exports = (http) => { expect(res.result).to.eql(expectedResult) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should put data and return a base64 encoded CID', async () => { + it('should put data and return a base64 encoded CID', async () => { const form = new FormData() form.append('file', JSON.stringify({ Data: 'TEST' + Date.now(), Links: [] }), { filename: 'node.json' }) const headers = form.getHeaders() @@ -258,8 +255,7 @@ module.exports = (http) => { expect(res.result.CumulativeSize).to.equal(60 + 8) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should stat object and return a base64 encoded CID', async () => { + it('should stat object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -366,8 +362,7 @@ module.exports = (http) => { expect(res.result).to.deep.equal(expectedResult) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should list object links and return a base64 encoded CID', async () => { + it('should list object links and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -509,8 +504,7 @@ module.exports = (http) => { expect(res.result).to.deep.equal(expectedResult) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should append data to object and return a base64 encoded CID', async () => { + it('should append data to object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -624,8 +618,7 @@ module.exports = (http) => { expect(res.result).to.deep.equal(expectedResult) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should set data for object and return a base64 encoded CID', async () => { + it('should set data for object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -731,8 +724,7 @@ module.exports = (http) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should add a link to an object and return a base64 encoded CID', async () => { + it('should add a link to an object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -820,8 +812,7 @@ module.exports = (http) => { expect(res.result.Hash).to.equal('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n') }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should remove a link from an object and return a base64 encoded CID', async () => { + it('should remove a link from an object and return a base64 encoded CID', async () => { const linkName = 'TEST' + Date.now() let res = await api.inject({ From 4c01608c1ac5e236be1a3862a339e5a908be822d Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 7 Feb 2019 15:14:03 +0000 Subject: [PATCH 05/16] refactor: CIDv1 for block and object License: MIT Signed-off-by: Alan Shaw --- src/core/components/block.js | 9 +-------- src/core/components/object.js | 9 ++++----- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/core/components/block.js b/src/core/components/block.js index 6a1bb960d1..290a767b62 100644 --- a/src/core/components/block.js +++ b/src/core/components/block.js @@ -56,16 +56,9 @@ module.exports = function block (self) { const mhtype = options.mhtype || 'sha2-256' const format = options.format || 'dag-pb' - let cidVersion + const cidVersion = options.version == null ? 1 : options.version // const mhlen = options.mhlen || 0 - if (options.version == null) { - // Pick appropriate CID version - cidVersion = mhtype === 'sha2-256' && format === 'dag-pb' ? 0 : 1 - } else { - cidVersion = options.version - } - multihashing(block, mhtype, (err, multihash) => { if (err) { return cb(err) diff --git a/src/core/components/object.js b/src/core/components/object.js index 85a3137522..77043ddbf3 100644 --- a/src/core/components/object.js +++ b/src/core/components/object.js @@ -8,7 +8,6 @@ const dagPB = require('ipld-dag-pb') const DAGNode = dagPB.DAGNode const DAGLink = dagPB.DAGLink const CID = require('cids') -const mh = require('multihashes') const Unixfs = require('ipfs-unixfs') const errCode = require('err-code') @@ -50,7 +49,7 @@ function parseJSONBuffer (buf, callback) { return new DAGLink( link.Name || link.name, link.Size || link.size, - mh.fromB58String(link.Hash || link.hash || link.multihash) + link.Hash || link.hash || link.multihash ) }) data = Buffer.from(parsed.Data) @@ -88,7 +87,7 @@ module.exports = function object (self) { } self._ipld.put(node, { - version: 0, + version: 1, hashAlg: 'sha2-256', format: 'dag-pb' }, (err, cid) => { @@ -138,7 +137,7 @@ module.exports = function object (self) { } self._ipld.put(node, { - version: 0, + version: 1, hashAlg: 'sha2-256', format: 'dag-pb' }, (err, cid) => { @@ -201,7 +200,7 @@ module.exports = function object (self) { function next () { self._ipld.put(node, { - version: 0, + version: 1, hashAlg: 'sha2-256', format: 'dag-pb' }, (err, cid) => { From c0088e52003707fe3cdbf209d569343a63222aa3 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 7 Feb 2019 15:19:20 +0000 Subject: [PATCH 06/16] chore: update ipld-dag-pb dependency License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1f460dfc07..61838eb008 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "ipfs-unixfs-engine": "github:ipfs/js-ipfs-unixfs-engine#refactor/cidv1b32-default", "ipld": "~0.21.1", "ipld-bitcoin": "~0.1.8", - "ipld-dag-pb": "~0.15.0", + "ipld-dag-pb": "github:ipld/js-ipld-dag-pb#refactor/cidv1b32-default", "ipld-ethereum": "^2.0.1", "ipld-git": "~0.2.2", "ipld-zcash": "~0.1.6", From c9138df3c498fa767907b0dfe2356fa79eeb02a9 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 6 Feb 2019 09:46:04 +0000 Subject: [PATCH 07/16] refactor: encode using CID v1 base32 by default License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- src/core/components/files-regular/add-pull-stream.js | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 6ca11e0338..2619f9782f 100644 --- a/package.json +++ b/package.json @@ -87,7 +87,7 @@ "bs58": "^4.0.1", "byteman": "^1.3.5", "cid-tool": "~0.2.0", - "cids": "~0.5.5", + "cids": "github:ipld/js-cid#refactor/cidv1base32-default", "class-is": "^1.1.0", "datastore-core": "~0.6.0", "datastore-pubsub": "~0.1.1", diff --git a/src/core/components/files-regular/add-pull-stream.js b/src/core/components/files-regular/add-pull-stream.js index 0d56b5e459..90ebfe373f 100644 --- a/src/core/components/files-regular/add-pull-stream.js +++ b/src/core/components/files-regular/add-pull-stream.js @@ -27,7 +27,7 @@ function prepareFile (file, self, opts, callback) { ? cb(null, file) : self.object.get(file.multihash, Object.assign({}, opts, { preload: false }), cb), (node, cb) => { - const b58Hash = cid.toBaseEncodedString() + const cidStr = cid.toBaseEncodedString() let size = node.size @@ -38,8 +38,8 @@ function prepareFile (file, self, opts, callback) { cb(null, { path: opts.wrapWithDirectory ? file.path.substring(WRAPPER.length) - : (file.path || b58Hash), - hash: b58Hash, + : (file.path || cidStr), + hash: cidStr, size }) } From 9d341e2d9d88333d5eaa20cf58c02a102521e86d Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 7 Feb 2019 08:59:25 +0000 Subject: [PATCH 08/16] chore: update ipfs-unixfs-engine dependency License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2619f9782f..1a7b442391 100644 --- a/package.json +++ b/package.json @@ -112,7 +112,7 @@ "ipfs-multipart": "~0.1.0", "ipfs-repo": "~0.26.1", "ipfs-unixfs": "~0.1.16", - "ipfs-unixfs-engine": "~0.35.3", + "ipfs-unixfs-engine": "github:ipfs/js-ipfs-unixfs-engine#refactor/cidv1b32-default", "ipld": "~0.21.1", "ipld-bitcoin": "~0.1.8", "ipld-dag-pb": "~0.15.0", From df7f01179355e7c33beb085fcc3310153bd4d139 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 7 Feb 2019 13:12:15 +0000 Subject: [PATCH 09/16] chore: update ipfs-mfs dependency License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1a7b442391..289a9721bc 100644 --- a/package.json +++ b/package.json @@ -108,7 +108,7 @@ "ipfs-block-service": "~0.15.1", "ipfs-http-client": "^29.0.0", "ipfs-http-response": "~0.2.1", - "ipfs-mfs": "~0.9.1", + "ipfs-mfs": "github:ipfs/js-ipfs-mfs#refactor/cidv1b32-default", "ipfs-multipart": "~0.1.0", "ipfs-repo": "~0.26.1", "ipfs-unixfs": "~0.1.16", From c3ebf1360c60105815e50093f4ec6e07bed07786 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 7 Feb 2019 15:06:20 +0000 Subject: [PATCH 10/16] test: unskip object tests License: MIT Signed-off-by: Alan Shaw --- test/cli/object.js | 18 ++++++------------ test/http-api/inject/object.js | 27 +++++++++------------------ 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/test/cli/object.js b/test/cli/object.js index ceb9f24627..10684aef25 100644 --- a/test/cli/object.js +++ b/test/cli/object.js @@ -34,8 +34,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should new and print CID encoded in specified base', () => { + it('should new and print CID encoded in specified base', () => { return ipfs('object new --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIOOwxEKY/BwUmvv0yJlvuSQnrkHkZJuTTKSVmRt4UrhV\n' @@ -103,8 +102,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should put and print CID encoded in specified base', () => { + it('should put and print CID encoded in specified base', () => { return ipfs('object put test/fixtures/test-data/node.json --cid-base=base64') .then((out) => { expect(out).to.eql( @@ -188,8 +186,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should append-data and print CID encoded in specified base', () => { + it('should append-data and print CID encoded in specified base', () => { return ipfs('object patch append-data QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n test/fixtures/test-data/badconfig --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIP+BZ7jGtaTyLGOs0xYcQvH7K9kVKEbyzXAkwLoZwrRj\n' @@ -205,8 +202,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should set-data and print CID encoded in specified base', () => { + it('should set-data and print CID encoded in specified base', () => { return ipfs('object patch set-data QmfY37rjbPCZRnhvvJuQ46htW3VCAWziVB991P79h6WSv6 test/fixtures/test-data/badconfig --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIP+BZ7jGtaTyLGOs0xYcQvH7K9kVKEbyzXAkwLoZwrRj\n' @@ -222,8 +218,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should add-link and print CID encoded in specified base', () => { + it('should add-link and print CID encoded in specified base', () => { return ipfs('object patch add-link QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n foo QmUNLLsPACCz1vLxQVkXqqLX5R1X345qqfHbsf67hvA3Nn --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIOEVPbXq2xYoEsRZhaPB61btcy1x359osjv4a2L/lgPs\n' @@ -239,8 +234,7 @@ describe('object', () => runOnAndOff((thing) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should rm-link and print CID encoded in specified base', () => { + it('should rm-link and print CID encoded in specified base', () => { return ipfs('object patch rm-link QmdVHE8fUD6FLNLugtNxqDFyhaCgdob372hs6BYEe75VAK foo --cid-base=base64').then((out) => { expect(out).to.eql( 'mAXASIOOwxEKY/BwUmvv0yJlvuSQnrkHkZJuTTKSVmRt4UrhV\n' diff --git a/test/http-api/inject/object.js b/test/http-api/inject/object.js index e329e98c64..13c5de8766 100644 --- a/test/http-api/inject/object.js +++ b/test/http-api/inject/object.js @@ -33,8 +33,7 @@ module.exports = (http) => { expect(res.result.Links).to.be.eql([]) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should create a new object and return a base64 encoded CID', async () => { + it('should create a new object and return a base64 encoded CID', async () => { const res = await api.inject({ method: 'POST', url: '/api/v0/object/new?cid-base=base64' @@ -88,8 +87,7 @@ module.exports = (http) => { expect(res.result.Data).to.be.empty() }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should get object and return a base64 encoded CID', async () => { + it('should get object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -185,8 +183,7 @@ module.exports = (http) => { expect(res.result).to.eql(expectedResult) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should put data and return a base64 encoded CID', async () => { + it('should put data and return a base64 encoded CID', async () => { const form = new FormData() form.append('file', JSON.stringify({ Data: 'TEST' + Date.now(), Links: [] }), { filename: 'node.json' }) const headers = form.getHeaders() @@ -258,8 +255,7 @@ module.exports = (http) => { expect(res.result.CumulativeSize).to.equal(60 + 8) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should stat object and return a base64 encoded CID', async () => { + it('should stat object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -366,8 +362,7 @@ module.exports = (http) => { expect(res.result).to.deep.equal(expectedResult) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should list object links and return a base64 encoded CID', async () => { + it('should list object links and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -509,8 +504,7 @@ module.exports = (http) => { expect(res.result).to.deep.equal(expectedResult) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should append data to object and return a base64 encoded CID', async () => { + it('should append data to object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -624,8 +618,7 @@ module.exports = (http) => { expect(res.result).to.deep.equal(expectedResult) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should set data for object and return a base64 encoded CID', async () => { + it('should set data for object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -731,8 +724,7 @@ module.exports = (http) => { }) }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should add a link to an object and return a base64 encoded CID', async () => { + it('should add a link to an object and return a base64 encoded CID', async () => { let res = await api.inject({ method: 'POST', url: '/api/v0/object/new' @@ -820,8 +812,7 @@ module.exports = (http) => { expect(res.result.Hash).to.equal('QmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n') }) - // TODO: unskip after switch to v1 CIDs by default - it.skip('should remove a link from an object and return a base64 encoded CID', async () => { + it('should remove a link from an object and return a base64 encoded CID', async () => { const linkName = 'TEST' + Date.now() let res = await api.inject({ From 5350a4a92da0e6926e08e850421f50f465e3de21 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 7 Feb 2019 15:14:03 +0000 Subject: [PATCH 11/16] refactor: CIDv1 for block and object License: MIT Signed-off-by: Alan Shaw --- src/core/components/block.js | 9 +-------- src/core/components/object.js | 9 ++++----- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/src/core/components/block.js b/src/core/components/block.js index 6a1bb960d1..290a767b62 100644 --- a/src/core/components/block.js +++ b/src/core/components/block.js @@ -56,16 +56,9 @@ module.exports = function block (self) { const mhtype = options.mhtype || 'sha2-256' const format = options.format || 'dag-pb' - let cidVersion + const cidVersion = options.version == null ? 1 : options.version // const mhlen = options.mhlen || 0 - if (options.version == null) { - // Pick appropriate CID version - cidVersion = mhtype === 'sha2-256' && format === 'dag-pb' ? 0 : 1 - } else { - cidVersion = options.version - } - multihashing(block, mhtype, (err, multihash) => { if (err) { return cb(err) diff --git a/src/core/components/object.js b/src/core/components/object.js index 85a3137522..77043ddbf3 100644 --- a/src/core/components/object.js +++ b/src/core/components/object.js @@ -8,7 +8,6 @@ const dagPB = require('ipld-dag-pb') const DAGNode = dagPB.DAGNode const DAGLink = dagPB.DAGLink const CID = require('cids') -const mh = require('multihashes') const Unixfs = require('ipfs-unixfs') const errCode = require('err-code') @@ -50,7 +49,7 @@ function parseJSONBuffer (buf, callback) { return new DAGLink( link.Name || link.name, link.Size || link.size, - mh.fromB58String(link.Hash || link.hash || link.multihash) + link.Hash || link.hash || link.multihash ) }) data = Buffer.from(parsed.Data) @@ -88,7 +87,7 @@ module.exports = function object (self) { } self._ipld.put(node, { - version: 0, + version: 1, hashAlg: 'sha2-256', format: 'dag-pb' }, (err, cid) => { @@ -138,7 +137,7 @@ module.exports = function object (self) { } self._ipld.put(node, { - version: 0, + version: 1, hashAlg: 'sha2-256', format: 'dag-pb' }, (err, cid) => { @@ -201,7 +200,7 @@ module.exports = function object (self) { function next () { self._ipld.put(node, { - version: 0, + version: 1, hashAlg: 'sha2-256', format: 'dag-pb' }, (err, cid) => { From df1f231cf3ce86e9213967dc23012af2592f77c4 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Thu, 7 Feb 2019 15:19:20 +0000 Subject: [PATCH 12/16] chore: update ipld-dag-pb dependency License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 289a9721bc..5aded46ee6 100644 --- a/package.json +++ b/package.json @@ -115,7 +115,7 @@ "ipfs-unixfs-engine": "github:ipfs/js-ipfs-unixfs-engine#refactor/cidv1b32-default", "ipld": "~0.21.1", "ipld-bitcoin": "~0.1.8", - "ipld-dag-pb": "~0.15.0", + "ipld-dag-pb": "github:ipld/js-ipld-dag-pb#refactor/cidv1b32-default", "ipld-ethereum": "^2.0.1", "ipld-git": "~0.2.2", "ipld-zcash": "~0.1.6", From f0bb08493c7417d03b605422494373959d633710 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Wed, 27 Feb 2019 14:02:23 +0000 Subject: [PATCH 13/16] chore: update interface-ipfs-core version License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5aded46ee6..653875d80f 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "execa": "^1.0.0", "form-data": "^2.3.3", "hat": "0.0.3", - "interface-ipfs-core": "~0.97.1", + "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#refactor/cidv1base32-default", "ipfsd-ctl": "~0.41.0", "libp2p-websocket-star": "~0.10.2", "ncp": "^2.0.0", From 263a58ac1c911b482615e5b3bb3b4ceba0104130 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 5 Mar 2019 16:30:23 +0000 Subject: [PATCH 14/16] chore: update dependencies License: MIT Signed-off-by: Alan Shaw --- package.json | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/package.json b/package.json index 61838eb008..ce7e22d45d 100644 --- a/package.json +++ b/package.json @@ -89,8 +89,8 @@ "boom": "^7.2.0", "bs58": "^4.0.1", "byteman": "^1.3.5", - "cid-tool": "~0.2.0", - "cids": "github:ipld/js-cid#refactor/cidv1base32-default", + "cid-tool": "github:multiformats/js-cid-tool#refactor/cidv1base32-default", + "cids": "github:multiformats/js-cid#refactor/cidv1base32-default", "class-is": "^1.1.0", "datastore-core": "~0.6.0", "datastore-pubsub": "~0.1.1", @@ -106,24 +106,24 @@ "hoek": "^6.1.2", "human-to-milliseconds": "^1.0.0", "interface-datastore": "~0.6.0", - "ipfs-bitswap": "~0.22.0", - "ipfs-block": "~0.8.0", + "ipfs-bitswap": "github:ipfs/js-ipfs-bitswap#refactor/cidv1base32-default", + "ipfs-block": "github:ipfs/js-ipfs-block#refactor/cidv1base32-default", "ipfs-block-service": "~0.15.1", "ipfs-http-client": "^29.0.0", - "ipfs-http-response": "~0.2.1", + "ipfs-http-response": "github:ipfs/js-ipfs-http-response#refactor/cidv1base32-default", "ipfs-mfs": "github:ipfs/js-ipfs-mfs#refactor/cidv1b32-default", "ipfs-multipart": "~0.1.0", "ipfs-repo": "~0.26.1", "ipfs-unixfs": "~0.1.16", "ipfs-unixfs-engine": "github:ipfs/js-ipfs-unixfs-engine#refactor/cidv1b32-default", - "ipld": "~0.21.1", - "ipld-bitcoin": "~0.1.8", + "ipld": "github:ipld/js-ipld#refactor/cidv1base32-default", + "ipld-bitcoin": "github:ipld/js-ipld-bitcoin#refactor/cidv1base32-default", "ipld-dag-pb": "github:ipld/js-ipld-dag-pb#refactor/cidv1b32-default", - "ipld-ethereum": "^2.0.1", - "ipld-git": "~0.2.2", - "ipld-zcash": "~0.1.6", + "ipld-ethereum": "github:ipld/js-ipld-ethereum#refactor/cidv1base32-default", + "ipld-git": "github:ipld/js-ipld-git#refactor/cidv1base32-default", + "ipld-zcash": "github:ipld/js-ipld-zcash#refactor/cidv1base32-default", "ipns": "~0.5.0", - "is-ipfs": "~0.4.8", + "is-ipfs": "github:ipfs/is-ipfs#refactor/cidv1base32-default", "is-pull-stream": "~0.0.0", "is-stream": "^1.1.0", "joi": "^14.3.0", From 67328b54b2bd65975a26c756d7240d61b276f6e1 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 5 Mar 2019 16:34:22 +0000 Subject: [PATCH 15/16] chore: update dependencies --- package.json | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/package.json b/package.json index e9d896e2a3..97858afb51 100644 --- a/package.json +++ b/package.json @@ -86,13 +86,8 @@ "boom": "^7.2.0", "bs58": "^4.0.1", "byteman": "^1.3.5", -<<<<<<< HEAD "cid-tool": "github:multiformats/js-cid-tool#refactor/cidv1base32-default", "cids": "github:multiformats/js-cid#refactor/cidv1base32-default", -======= - "cid-tool": "~0.2.0", - "cids": "github:ipld/js-cid#refactor/cidv1base32-default", ->>>>>>> f0bb08493c7417d03b605422494373959d633710 "class-is": "^1.1.0", "datastore-core": "~0.6.0", "datastore-pubsub": "~0.1.1", @@ -112,31 +107,18 @@ "ipfs-block": "github:ipfs/js-ipfs-block#refactor/cidv1base32-default", "ipfs-block-service": "~0.15.1", "ipfs-http-client": "^29.0.0", -<<<<<<< HEAD "ipfs-http-response": "github:ipfs/js-ipfs-http-response#refactor/cidv1base32-default", -======= - "ipfs-http-response": "~0.2.1", ->>>>>>> f0bb08493c7417d03b605422494373959d633710 "ipfs-mfs": "github:ipfs/js-ipfs-mfs#refactor/cidv1b32-default", "ipfs-multipart": "~0.1.0", "ipfs-repo": "~0.26.1", "ipfs-unixfs": "~0.1.16", "ipfs-unixfs-engine": "github:ipfs/js-ipfs-unixfs-engine#refactor/cidv1b32-default", -<<<<<<< HEAD "ipld": "github:ipld/js-ipld#refactor/cidv1base32-default", "ipld-bitcoin": "github:ipld/js-ipld-bitcoin#refactor/cidv1base32-default", "ipld-dag-pb": "github:ipld/js-ipld-dag-pb#refactor/cidv1b32-default", "ipld-ethereum": "github:ipld/js-ipld-ethereum#refactor/cidv1base32-default", "ipld-git": "github:ipld/js-ipld-git#refactor/cidv1base32-default", "ipld-zcash": "github:ipld/js-ipld-zcash#refactor/cidv1base32-default", -======= - "ipld": "~0.21.1", - "ipld-bitcoin": "~0.1.8", - "ipld-dag-pb": "github:ipld/js-ipld-dag-pb#refactor/cidv1b32-default", - "ipld-ethereum": "^2.0.1", - "ipld-git": "~0.2.2", - "ipld-zcash": "~0.1.6", ->>>>>>> f0bb08493c7417d03b605422494373959d633710 "ipns": "~0.5.0", "is-ipfs": "github:ipfs/is-ipfs#refactor/cidv1base32-default", "is-pull-stream": "~0.0.0", From a7bc1ce041ba662d8e3c3d4f13fd00bae58d9539 Mon Sep 17 00:00:00 2001 From: Alan Shaw Date: Tue, 12 Mar 2019 20:23:10 +0000 Subject: [PATCH 16/16] fix: interface-ipfs-core version License: MIT Signed-off-by: Alan Shaw --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 97858afb51..1ce98a121d 100644 --- a/package.json +++ b/package.json @@ -68,7 +68,7 @@ "execa": "^1.0.0", "form-data": "^2.3.3", "hat": "0.0.3", - "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#refactor/cidv1base32-default", + "interface-ipfs-core": "github:ipfs/interface-js-ipfs-core#refactor/cidv1b32-default", "ipfsd-ctl": "~0.41.0", "libp2p-websocket-star": "~0.10.2", "ncp": "^2.0.0",