-
Notifications
You must be signed in to change notification settings - Fork 1.2k
feat/awesome dag-pb #625
feat/awesome dag-pb #625
Changes from all commits
12325a2
db550a1
265a77a
3fa1438
1132f33
ca9935f
3bb3ba8
698f708
7fad4d8
443dd9e
20e3d2e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,4 +9,5 @@ module.exports = { | |
included: false | ||
}] | ||
} | ||
} | ||
} | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
'use strict' | ||
|
||
var path = require('path') | ||
var webpack = require('webpack') | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,14 +54,15 @@ | |
"buffer-loader": "0.0.1", | ||
"chai": "^3.5.0", | ||
"detect-node": "^2.0.3", | ||
"eslint-plugin-react": "^6.7.1", | ||
"execa": "^0.5.0", | ||
"expose-loader": "^0.7.1", | ||
"form-data": "^2.1.2", | ||
"fs-pull-blob-store": "^0.4.1", | ||
"gulp": "^3.9.1", | ||
"interface-ipfs-core": "^0.18.4", | ||
"interface-ipfs-core": "^0.22.0", | ||
"left-pad": "^1.1.3", | ||
"lodash": "^4.17.1", | ||
"lodash": "^4.17.2", | ||
"ncp": "^2.0.0", | ||
"nexpect": "^0.5.0", | ||
"pre-commit": "^1.1.3", | ||
|
@@ -70,7 +71,7 @@ | |
"transform-loader": "^0.2.3" | ||
}, | ||
"dependencies": { | ||
"async": "^2.1.2", | ||
"async": "^2.1.4", | ||
"bl": "^1.1.2", | ||
"boom": "^4.2.0", | ||
"debug": "^2.3.3", | ||
|
@@ -79,17 +80,17 @@ | |
"hapi": "^15.2.0", | ||
"hapi-set-header": "^1.0.2", | ||
"idb-pull-blob-store": "^0.5.1", | ||
"ipfs-api": "^11.1.0", | ||
"ipfs-api": "^12.0.0", | ||
"ipfs-bitswap": "^0.8.1", | ||
"ipfs-block": "^0.5.0", | ||
"ipfs-block-service": "^0.7.0", | ||
"ipfs-multipart": "^0.1.0", | ||
"ipfs-repo": "^0.11.1", | ||
"ipfs-unixfs": "^0.1.5", | ||
"ipfs-unixfs-engine": "^0.13.0", | ||
"ipld-resolver": "^0.2.0", | ||
"ipfs-unixfs-engine": "^0.14.0", | ||
"ipld-resolver": "^0.3.0", | ||
"isstream": "^0.1.2", | ||
"joi": "^9.2.0", | ||
"joi": "^10.0.1", | ||
"libp2p-ipfs": "^0.15.0", | ||
"libp2p-ipfs-browser": "^0.16.0", | ||
"lodash.flatmap": "^4.5.0", | ||
|
@@ -99,12 +100,12 @@ | |
"lodash.sortby": "^4.7.0", | ||
"lodash.values": "^4.3.0", | ||
"mafmt": "^2.1.2", | ||
"multiaddr": "^2.0.3", | ||
"multiaddr": "^2.1.1", | ||
"multihashes": "^0.2.2", | ||
"path-exists": "^3.0.0", | ||
"peer-book": "^0.3.0", | ||
"peer-id": "^0.8.0", | ||
"peer-info": "^0.8.0", | ||
"peer-info": "^0.8.1", | ||
"promisify-es6": "^1.0.2", | ||
"pull-file": "^1.0.0", | ||
"pull-paramap": "^1.2.1", | ||
|
@@ -114,7 +115,7 @@ | |
"pull-stream-to-stream": "^1.3.3", | ||
"pull-zip": "^2.0.1", | ||
"read-pkg-up": "^2.0.0", | ||
"readable-stream": "^1.1.14", | ||
"readable-stream": "1.1.14", | ||
"stream-to-pull-stream": "^1.7.2", | ||
"tar-stream": "^1.5.2", | ||
"temp": "^0.8.3", | ||
|
@@ -147,4 +148,4 @@ | |
"nginnever <[email protected]>", | ||
"npmcdn-to-unpkg-bot <[email protected]>" | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,15 +16,29 @@ module.exports = { | |
handler (argv) { | ||
waterfall([ | ||
(cb) => utils.getIPFS(cb), | ||
(ipfs, cb) => ipfs.object.get(argv.key, {enc: 'base58'}, cb), | ||
(node, cb) => node.toJSON(cb) | ||
], (err, nodeJson) => { | ||
(ipfs, cb) => ipfs.object.get(argv.key, {enc: 'base58'}, cb) | ||
], (err, node) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please refrain from these cosmetic changes, I will change it back in the next commit any way and it makes it harder to see the relevant changes. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fair point! :) |
||
if (err) { | ||
throw err | ||
} | ||
const nodeJSON = node.toJSON() | ||
|
||
nodeJson.Data = nodeJson.Data ? nodeJson.Data.toString() : '' | ||
console.log(JSON.stringify(nodeJson)) | ||
nodeJSON.data = nodeJSON.data ? nodeJSON.data.toString() : '' | ||
|
||
const answer = { | ||
Data: nodeJSON.data, | ||
Hash: nodeJSON.multihash, | ||
Size: nodeJSON.size, | ||
Links: nodeJSON.links.map((l) => { | ||
return { | ||
Name: l.name, | ||
Size: l.size, | ||
Hash: l.multihash | ||
} | ||
}) | ||
} | ||
|
||
console.log(JSON.stringify(answer)) | ||
}) | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,8 +5,7 @@ const debug = require('debug') | |
const log = debug('cli:object') | ||
const dagPB = require('ipld-dag-pb') | ||
const DAGLink = dagPB.DAGLink | ||
const waterfall = require('async/waterfall') | ||
const parallel = require('async/parallel') | ||
const series = require('async/series') | ||
log.error = debug('cli:object:error') | ||
|
||
module.exports = { | ||
|
@@ -17,29 +16,46 @@ module.exports = { | |
builder: {}, | ||
|
||
handler (argv) { | ||
waterfall([ | ||
(cb) => utils.getIPFS(cb), | ||
(ipfs, cb) => waterfall([ | ||
(cb) => ipfs.object.get(argv.ref, {enc: 'base58'}, cb), | ||
(linkedObj, cb) => parallel([ | ||
(cb) => linkedObj.size(cb), | ||
(cb) => linkedObj.multihash(cb) | ||
], cb) | ||
], (err, stats) => { | ||
if (err) { | ||
return cb(err) | ||
} | ||
|
||
const link = new DAGLink(argv.name, stats[0], stats[1]) | ||
ipfs.object.patch.addLink(argv.root, link, {enc: 'base58'}, cb) | ||
}), | ||
(node, cb) => node.toJSON(cb) | ||
], (err, node) => { | ||
let ipfs | ||
let nodeA | ||
let nodeB | ||
|
||
series([ | ||
(cb) => { | ||
utils.getIPFS((err, _ipfs) => { | ||
if (err) { | ||
return cb(err) | ||
} | ||
ipfs = _ipfs | ||
cb() | ||
}) | ||
}, | ||
(cb) => { | ||
ipfs.object.get(argv.ref, {enc: 'base58'}, (err, node) => { | ||
if (err) { | ||
return cb(err) | ||
} | ||
nodeA = node | ||
cb() | ||
}) | ||
}, | ||
(cb) => { | ||
const link = new DAGLink(argv.name, nodeA.size, nodeA.multihash) | ||
|
||
ipfs.object.patch.addLink(argv.root, link, {enc: 'base58'}, (err, node) => { | ||
if (err) { | ||
return cb(err) | ||
} | ||
nodeB = node | ||
cb() | ||
}) | ||
} | ||
], (err) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a lot more complex and harder to read then before :( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is also my attempt of trying to break each step by parts so that I can debug what is happening |
||
if (err) { | ||
throw err | ||
} | ||
|
||
console.log(node.Hash) | ||
console.log(nodeB.toJSON().multihash) | ||
}) | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, it was because of the added example? 💥
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes