From 6b61438bcab83a2924ed25a761c17bba56d6b010 Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 29 May 2017 10:10:53 +0100 Subject: [PATCH 1/3] feat: support new block.put API --- src/core/components/block.js | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/src/core/components/block.js b/src/core/components/block.js index 1d06e1220e..7027d8302f 100644 --- a/src/core/components/block.js +++ b/src/core/components/block.js @@ -12,7 +12,12 @@ module.exports = function block (self) { cid = cleanCid(cid) self._blockService.get(cid, callback) }, - put: (block, callback) => { + put: (block, options, callback) => { + if (typeof options === 'function') { + callback = options + options = {} + } + if (Array.isArray(block)) { return callback(new Error('Array is not supported')) } @@ -23,12 +28,21 @@ module.exports = function block (self) { return cb(null, block) } - multihashing(block, 'sha2-256', (err, multihash) => { + if (options.cid && CID.isCID(options.cid)) { + return cb(null, new Block(block, options.cid)) + } + + const mhtype = options.mhtype || 'sha2-256' + const format = options.format || 'dag-pb' + const cidVersion = options.version || 0 + // const mhlen = options.mhlen || 0 + + multihashing(block, mhtype, (err, multihash) => { if (err) { return cb(err) } - cb(null, new Block(block, new CID(multihash))) + cb(null, new Block(block, new CID(cidVersion, format, multihash))) }) }, (block, cb) => self._blockService.put(block, (err) => { From e67c35e7e1ba714521021a623effc48946c8ed3f Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 29 May 2017 10:11:03 +0100 Subject: [PATCH 2/3] chore: update package-lock --- package-lock.json | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index 395ea2f980..ffb1c1aa94 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1109,9 +1109,9 @@ "integrity": "sha1-FK1hE4EtLTfXLme0ystLtyZQXxE=" }, "bip66": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.4.tgz", - "integrity": "sha1-iln4rhbsy5RoHDwqeyJHdGBarfs=" + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/bip66/-/bip66-1.1.5.tgz", + "integrity": "sha1-AfqHSHhcpwlV1QESF9GzE5lpyiI=" }, "bl": { "version": "1.2.1", @@ -1735,9 +1735,9 @@ "integrity": "sha1-yj3eBEgPElGbcVJuxEvUiN37P+8=", "dependencies": { "boom": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-5.0.0.tgz", - "integrity": "sha1-sZ9OUKI/ic3YF8Z+UNud8u84OL0=" + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/boom/-/boom-5.1.0.tgz", + "integrity": "sha1-Awj6jpJM1tQtnDv0iDvcmPDnHfg=" } } }, @@ -1866,9 +1866,9 @@ "integrity": "sha1-4ye1MZThp61dxjR57pCZpSsCSGU=" }, "conventional-github-releaser": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/conventional-github-releaser/-/conventional-github-releaser-1.1.5.tgz", - "integrity": "sha1-8AMlhfUd0DtSBJDtKGSrHwWZa7s=" + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/conventional-github-releaser/-/conventional-github-releaser-1.1.7.tgz", + "integrity": "sha1-N0snHpkBpGM/Bfquf4xw/HrLYus=" }, "convert-source-map": { "version": "1.5.0", @@ -5405,7 +5405,7 @@ "integrity": "sha1-dc449SvwczxafwwRjYEzSiu19BI=" }, "uglify-es": { - "version": "github:mishoo/UglifyJS2#e5e0ce0b42307fe7d535376c39caa02d5d823fe2" + "version": "github:mishoo/UglifyJS2#ee23a84e1492b4c38e343c41cacd224b54c203ac" } } }, @@ -5798,9 +5798,9 @@ "optional": true }, "joi": { - "version": "10.5.0", - "resolved": "https://registry.npmjs.org/joi/-/joi-10.5.0.tgz", - "integrity": "sha512-5daUVp9m1B/9HKsCWxxSOHFChCkfiz95sTQg+XQawtVd9OekXcRWE8R6a7X4F/Es0/CPnF7cRA5+NstMJB0X7g==" + "version": "10.5.1", + "resolved": "https://registry.npmjs.org/joi/-/joi-10.5.1.tgz", + "integrity": "sha1-IsYI0QbB9/4YxvG/OKIo/fLaq38=" }, "js-sha3": { "version": "0.5.7", @@ -7977,9 +7977,9 @@ "integrity": "sha1-YACg/QGIhM39c3JU+Mxgqypjd5E=" }, "pull-length-prefixed": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/pull-length-prefixed/-/pull-length-prefixed-1.2.1.tgz", - "integrity": "sha1-+gDKFCqF80epHWwS2kFu9WWYl9w=" + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/pull-length-prefixed/-/pull-length-prefixed-1.3.0.tgz", + "integrity": "sha512-FkxMYPNUSFjEDEXuS6MAaKwagQAN0sonifeC+NeutQmgXy+WBdPOtPzDT1dyT69Io1wzraZ+GzXAbBGnFcjdFQ==" }, "pull-many": { "version": "1.0.8", From 6b0bad26b8d6b25cd6c9bc9b463bb271b37193bd Mon Sep 17 00:00:00 2001 From: David Dias Date: Mon, 29 May 2017 10:28:41 +0100 Subject: [PATCH 3/3] chore: update deps --- package-lock.json | 63 ++++++++++++++++++++++++++++------------------- package.json | 12 ++++----- 2 files changed, 43 insertions(+), 32 deletions(-) diff --git a/package-lock.json b/package-lock.json index ffb1c1aa94..7a950bc1f1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1183,9 +1183,9 @@ } }, "boom": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/boom/-/boom-4.3.1.tgz", - "integrity": "sha1-T4owBctKfjiJ90kDD9JbluAdLjE=" + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/boom/-/boom-5.1.0.tgz", + "integrity": "sha1-Awj6jpJM1tQtnDv0iDvcmPDnHfg=" }, "borc": { "version": "2.0.2", @@ -1463,9 +1463,9 @@ "integrity": "sha1-qg0yYptu6XIgBBHL1EYckHvCt60=" }, "chai": { - "version": "3.5.0", - "resolved": "https://registry.npmjs.org/chai/-/chai-3.5.0.tgz", - "integrity": "sha1-TQJjewZ/6Vi9v906QOxW/vc3Mkc=", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/chai/-/chai-4.0.0.tgz", + "integrity": "sha1-9smJ5FpXB9QMVNl93XyomzCmoGo=", "dev": true }, "chainsaw": { @@ -1507,6 +1507,12 @@ "resolved": "https://registry.npmjs.org/character-reference-invalid/-/character-reference-invalid-1.1.0.tgz", "integrity": "sha1-3smtHfufjQa0/NqircPE/ZevHmg=" }, + "check-error": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", + "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", + "dev": true + }, "chokidar": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-1.7.0.tgz", @@ -1732,14 +1738,7 @@ "content": { "version": "3.0.4", "resolved": "https://registry.npmjs.org/content/-/content-3.0.4.tgz", - "integrity": "sha1-yj3eBEgPElGbcVJuxEvUiN37P+8=", - "dependencies": { - "boom": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/boom/-/boom-5.1.0.tgz", - "integrity": "sha1-Awj6jpJM1tQtnDv0iDvcmPDnHfg=" - } - } + "integrity": "sha1-yj3eBEgPElGbcVJuxEvUiN37P+8=" }, "content-type": { "version": "1.0.2", @@ -2165,15 +2164,15 @@ } }, "deep-eql": { - "version": "0.1.3", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-0.1.3.tgz", - "integrity": "sha1-71WKyrjeJSBs1xOQbXTlaTDrafI=", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-2.0.2.tgz", + "integrity": "sha1-sbrAblbwp2d3aG1Qyf63XC7XZ5o=", "dev": true, "dependencies": { "type-detect": { - "version": "0.1.1", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-0.1.1.tgz", - "integrity": "sha1-C6XsKohWQORw6k6FBZcZANrFiCI=", + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-3.0.0.tgz", + "integrity": "sha1-RtDMhVOrt7E6NSsNbeov1Y8tm1U=", "dev": true } } @@ -3793,6 +3792,12 @@ "resolved": "https://registry.npmjs.org/get-comments/-/get-comments-1.0.1.tgz", "integrity": "sha1-GWdZEBu7xPrPEwYMqu3Uhw3uVb4=" }, + "get-func-name": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", + "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", + "dev": true + }, "get-pkg-repo": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/get-pkg-repo/-/get-pkg-repo-1.3.0.tgz", @@ -5127,9 +5132,9 @@ "integrity": "sha1-o8ZvEuFKR8iA2KUacm90RrLaKNE=" }, "interface-ipfs-core": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/interface-ipfs-core/-/interface-ipfs-core-0.27.2.tgz", - "integrity": "sha1-2YcvcaFC7DGRkGX0QbmnNmlbI3Y=", + "version": "0.28.0", + "resolved": "https://registry.npmjs.org/interface-ipfs-core/-/interface-ipfs-core-0.28.0.tgz", + "integrity": "sha512-tskrOHzXdtcF7OpDPcYtLixdaCRknoSgWOEsothXG5t/mq6zG1sZ95KRWr3WqkA4/nbH4rN4LY4WNGMoEh8iGg==", "dev": true }, "interpret": { @@ -7699,6 +7704,12 @@ "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=" }, + "pathval": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.0.tgz", + "integrity": "sha1-uULm1L3mUwBe9rcTYd74cn0GReA=", + "dev": true + }, "pbkdf2": { "version": "3.0.12", "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.12.tgz", @@ -9567,9 +9578,9 @@ "integrity": "sha1-WITKtRLPHTVeP7eE8wgEsrUg23I=" }, "type-detect": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-1.0.0.tgz", - "integrity": "sha1-diIXzAbbJY7EiQihKY6LlRIejqI=", + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.3.tgz", + "integrity": "sha1-Dj8mcLRAmbC0bChNE2p+9Jx0wuo=", "dev": true }, "type-is": { diff --git a/package.json b/package.json index 76b6b1bfa8..08843c583a 100644 --- a/package.json +++ b/package.json @@ -62,7 +62,7 @@ "devDependencies": { "aegir": "^11.0.2", "buffer-loader": "0.0.1", - "chai": "^3.5.0", + "chai": "^4.0.0", "delay": "^2.0.0", "detect-node": "^2.0.3", "dir-compare": "^1.4.0", @@ -72,11 +72,11 @@ "expose-loader": "^0.7.3", "form-data": "^2.1.4", "gulp": "^3.9.1", - "interface-ipfs-core": "~0.27.2", + "interface-ipfs-core": "~0.28.0", "ipfsd-ctl": "~0.21.0", "left-pad": "^1.1.3", "lodash": "^4.17.4", - "mocha": "^3.4.1", + "mocha": "^3.4.2", "ncp": "^2.0.0", "nexpect": "^0.5.0", "pre-commit": "^1.2.2", @@ -90,7 +90,7 @@ "dependencies": { "async": "^2.4.1", "bl": "^1.2.1", - "boom": "^4.3.1", + "boom": "^5.1.0", "cids": "^0.5.0", "debug": "^2.6.8", "fsm-event": "^2.1.0", @@ -105,10 +105,10 @@ "ipfs-multipart": "~0.1.0", "ipfs-repo": "~0.13.1", "ipfs-unixfs": "~0.1.11", - "ipfs-unixfs-engine": "~0.19.1", + "ipfs-unixfs-engine": "~0.19.2", "ipld-resolver": "~0.11.1", "isstream": "^0.1.2", - "joi": "^10.5.0", + "joi": "^10.5.1", "libp2p-floodsub": "~0.9.4", "libp2p-ipfs-browser": "~0.24.1", "libp2p-ipfs-nodejs": "~0.25.2",