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

Commit d27c003

Browse files
achingbrainAlan Shaw
authored and
Alan Shaw
committed
refactor: update ipld formats, async/await mfs/unixfs & base32 cids (#2068)
This is part of the Awesome Endeavour: Async Iterators: ipfs/js-ipfs#1670 Depends on * [x] ipld/js-ipld-dag-pb#137 * [x] ipfs-inactive/interface-js-ipfs-core#473 * [x] ipfs-inactive/js-ipfs-http-client#1010 * [x] ipfs/js-ipfs-http-response#25 resolves #1995 BREAKING CHANGE: The default string encoding for version 1 CIDs has changed to `base32`. IPLD formats have been updated to the latest versions. IPLD nodes returned by `ipfs.dag` and `ipfs.object` commands have significant breaking changes. If you are using these commands in your application you are likely to encounter the following changes to `dag-pb` nodes (the default node type that IPFS creates): * `DAGNode` properties have been renamed as follows: * `data` => `Data` * `links` => `Links` * `size` => `size` (Note: no change) * `DAGLink` properties have been renamed as follows: * `cid` => `Hash` * `name` => `Name` * `size` => `Tsize` See CHANGELOGs for each IPLD format for it's respective changes, you can read more about the [`dag-pb` changes in the CHANGELOG](https://github.com/ipld/js-ipld-dag-pb/blob/master) License: MIT Signed-off-by: Alan Shaw <[email protected]>
1 parent 71b4f4c commit d27c003

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

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

+10-9
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@ createNode((err, ipfs) => {
1717
series([
1818
(cb) => {
1919
const someData = Buffer.from('capoeira')
20+
let node
2021

21-
dagPB.DAGNode.create(someData, (err, node) => {
22+
try {
23+
node = dagPB.DAGNode.create(someData)
24+
} catch (err) {
25+
return cb(err)
26+
}
27+
28+
ipfs.dag.put(node, { format: 'dag-pb', hashAlg: 'sha2-256' }, (err, cid) => {
2229
if (err) {
2330
cb(err)
2431
}
25-
26-
ipfs.dag.put(node, { format: 'dag-pb', hashAlg: 'sha2-256' }, (err, cid) => {
27-
if (err) {
28-
cb(err)
29-
}
30-
cidPBNode = cid
31-
cb()
32-
})
32+
cidPBNode = cid
33+
cb()
3334
})
3435
},
3536
(cb) => {

traverse-ipld-graphs/tree.js

+10-9
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,20 @@ createNode((err, ipfs) => {
1717
series([
1818
(cb) => {
1919
const someData = Buffer.from('capoeira')
20+
let node
2021

21-
dagPB.DAGNode.create(someData, (err, node) => {
22+
try {
23+
dagPB.DAGNode.create(someData)
24+
} catch (err) {
25+
return cb(err)
26+
}
27+
28+
ipfs.dag.put(node, { format: 'dag-pb', hashAlg: 'sha2-256' }, (err, cid) => {
2229
if (err) {
2330
cb(err)
2431
}
25-
26-
ipfs.dag.put(node, { format: 'dag-pb', hashAlg: 'sha2-256' }, (err, cid) => {
27-
if (err) {
28-
cb(err)
29-
}
30-
cidPBNode = cid
31-
cb()
32-
})
32+
cidPBNode = cid
33+
cb()
3334
})
3435
},
3536
(cb) => {

0 commit comments

Comments
 (0)