This repository was archived by the owner on Feb 12, 2024. It is now read-only.
File tree 7 files changed +65
-19
lines changed
7 files changed +65
-19
lines changed Original file line number Diff line number Diff line change @@ -23,9 +23,13 @@ module.exports = {
23
23
throw err
24
24
}
25
25
26
- const res = node . toJSON ( )
27
- res . Data = res . Data ? res . Data . toString ( ) : ''
28
- console . log ( JSON . stringify ( res ) )
26
+ node . toJSON ( ( err , nodeJSON ) => {
27
+ if ( err ) {
28
+ throw err
29
+ }
30
+ nodeJSON . Data = nodeJSON . Data ? nodeJSON . Data . toString ( ) : ''
31
+ console . log ( JSON . stringify ( nodeJSON ) )
32
+ } )
29
33
} )
30
34
} )
31
35
}
Original file line number Diff line number Diff line change @@ -23,7 +23,12 @@ module.exports = {
23
23
throw err
24
24
}
25
25
26
- console . log ( node . toJSON ( ) . Hash )
26
+ node . toJSON ( ( err , nodeJSON ) => {
27
+ if ( err ) {
28
+ throw err
29
+ }
30
+ console . log ( nodeJSON . Hash )
31
+ } )
27
32
} )
28
33
} )
29
34
}
Original file line number Diff line number Diff line change 3
3
const utils = require ( '../../../utils' )
4
4
const debug = require ( 'debug' )
5
5
const log = debug ( 'cli:object' )
6
- const mDAG = require ( 'ipfs-merkle- dag' )
7
- const DAGLink = mDAG . DAGLink
6
+ const dagPB = require ( 'ipld- dag-pb ' )
7
+ const DAGLink = dagPB . DAGLink
8
8
log . error = debug ( 'cli:object:error' )
9
9
10
10
module . exports = {
@@ -21,14 +21,28 @@ module.exports = {
21
21
}
22
22
23
23
ipfs . object . get ( argv . ref , { enc : 'base58' } ) . then ( ( linkedObj ) => {
24
- const link = new DAGLink (
25
- argv . name ,
26
- linkedObj . size ( ) ,
27
- linkedObj . multihash ( )
28
- )
29
- return ipfs . object . patch . addLink ( argv . root , link , { enc : 'base58' } )
30
- } ) . then ( ( node ) => {
31
- console . log ( node . toJSON ( ) . Hash )
24
+ linkedObj . size ( ( err , size ) => {
25
+ if ( err ) {
26
+ throw err
27
+ }
28
+ linkedObj . multihash ( ( err , multihash ) => {
29
+ if ( err ) {
30
+ throw err
31
+ }
32
+
33
+ const link = new DAGLink ( argv . name , size , multihash )
34
+
35
+ ipfs . object . patch . addLink ( argv . root , link , { enc : 'base58' } )
36
+ . then ( ( node ) => {
37
+ node . toJSON ( ( err , nodeJSON ) => {
38
+ if ( err ) {
39
+ throw err
40
+ }
41
+ console . log ( nodeJSON . Hash )
42
+ } )
43
+ } )
44
+ } )
45
+ } )
32
46
} ) . catch ( ( err ) => {
33
47
throw err
34
48
} )
Original file line number Diff line number Diff line change @@ -18,7 +18,13 @@ function appendData (key, data) {
18
18
throw err
19
19
}
20
20
21
- console . log ( node . toJSON ( ) . Hash )
21
+ node . toJSON ( ( err , nodeJSON ) => {
22
+ if ( err ) {
23
+ throw err
24
+ }
25
+
26
+ console . log ( nodeJSON . Hash )
27
+ } )
22
28
} )
23
29
} )
24
30
}
Original file line number Diff line number Diff line change 1
1
'use strict'
2
2
3
- const DAGLink = require ( 'ipfs-merkle- dag' ) . DAGLink
3
+ const DAGLink = require ( 'ipld- dag-pb ' ) . DAGLink
4
4
const utils = require ( '../../../utils' )
5
5
const debug = require ( 'debug' )
6
6
const log = debug ( 'cli:object' )
@@ -26,7 +26,12 @@ module.exports = {
26
26
throw err
27
27
}
28
28
29
- console . log ( node . toJSON ( ) . Hash )
29
+ node . toJSON ( ( err , nodeJSON ) => {
30
+ if ( err ) {
31
+ throw err
32
+ }
33
+ console . log ( nodeJSON . Hash )
34
+ } )
30
35
} )
31
36
} )
32
37
}
Original file line number Diff line number Diff line change @@ -18,7 +18,13 @@ function parseAndAddNode (key, data) {
18
18
throw err
19
19
}
20
20
21
- console . log ( node . toJSON ( ) . Hash )
21
+ node . toJSON ( ( err , nodeJSON ) => {
22
+ if ( err ) {
23
+ throw err
24
+ }
25
+
26
+ console . log ( nodeJSON . Hash )
27
+ } )
22
28
} )
23
29
} )
24
30
}
Original file line number Diff line number Diff line change @@ -18,7 +18,13 @@ function putNode (buf, enc) {
18
18
throw err
19
19
}
20
20
21
- console . log ( 'added' , node . toJSON ( ) . Hash )
21
+ node . toJSON ( ( err , nodeJSON ) => {
22
+ if ( err ) {
23
+ throw err
24
+ }
25
+
26
+ console . log ( 'added' , nodeJSON . Hash )
27
+ } )
22
28
} )
23
29
} )
24
30
}
You can’t perform that action at this time.
0 commit comments