This repository was archived by the owner on Mar 10, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +36
-14
lines changed Expand file tree Collapse file tree 2 files changed +36
-14
lines changed Original file line number Diff line number Diff line change 22 "name" : " ipfs-api" ,
33 "version" : " 9.0.0" ,
44 "description" : " A client library for the IPFS HTTP API. Follows interface-ipfs-core spec" ,
5- "main" : " src /index.js" ,
5+ "main" : " lib /index.js" ,
66 "jsnext:main" : " src/index.js" ,
77 "scripts" : {
88 "test" : " node --max_old_space_size=4096 node_modules/.bin/gulp test:node" ,
2525 "flatmap" : " 0.0.3" ,
2626 "glob" : " ^7.1.1" ,
2727 "ipfs-block" : " ^0.4.0" ,
28- "ipld-dag-pb" : " ^0.1.2 " ,
28+ "ipld-dag-pb" : " ^0.1.3 " ,
2929 "is-ipfs" : " ^0.2.0" ,
3030 "isstream" : " ^0.1.2" ,
3131 "multiaddr" : " ^2.0.2" ,
5151 "chai" : " ^3.5.0" ,
5252 "gulp" : " ^3.9.1" ,
5353 "hapi" : " ^15.2.0" ,
54- "interface-ipfs-core" : " ^0.15.0 " ,
54+ "interface-ipfs-core" : " ^0.16.1 " ,
5555 "ipfsd-ctl" : " ^0.16.0" ,
5656 "pre-commit" : " ^1.1.3" ,
5757 "socket.io" : " ^1.5.1" ,
Original file line number Diff line number Diff line change @@ -94,21 +94,37 @@ module.exports = (send) => {
9494 obj = JSON . parse ( obj . toString ( ) )
9595 }
9696 }
97+
9798 let node
99+
98100 if ( obj . multihash ) {
99101 node = obj
100102 } else if ( options . enc === 'protobuf' ) {
101- node = new DAGNode ( )
102- node . unMarshal ( obj )
103+ dagPB . util . deserialize ( obj , ( err , _node ) => {
104+ if ( err ) {
105+ return callback ( err )
106+ }
107+ node = _node
108+ next ( )
109+ } )
110+ return
103111 } else {
104112 node = new DAGNode ( obj . Data , obj . Links )
105113 }
106-
107- if ( node . toJSON ( ) . Hash !== result . Hash ) {
108- return callback ( new Error ( 'Stored object was different from constructed object' ) )
114+ next ( )
115+
116+ function next ( ) {
117+ node . toJSON ( ( err , nodeJSON ) => {
118+ if ( err ) {
119+ return callback ( err )
120+ }
121+ if ( nodeJSON . Hash !== result . Hash ) {
122+ return callback ( new Error ( 'Stored object was different from constructed object' ) )
123+ }
124+
125+ callback ( null , node )
126+ } )
109127 }
110-
111- callback ( null , node )
112128 } )
113129 } ) ,
114130 data : promisify ( ( multihash , options , callback ) => {
@@ -201,13 +217,19 @@ module.exports = (send) => {
201217 if ( err ) {
202218 return callback ( err )
203219 }
220+
204221 const node = new DAGNode ( )
222+ node . toJSON ( ( err , nodeJSON ) => {
223+ if ( err ) {
224+ return callback ( err )
225+ }
205226
206- if ( node . toJSON ( ) . Hash !== result . Hash ) {
207- return callback ( new Error ( 'Stored object was different from constructed object' ) )
208- }
227+ if ( nodeJSON . Hash !== result . Hash ) {
228+ return callback ( new Error ( 'Stored object was different from constructed object' ) )
229+ }
209230
210- callback ( null , node )
231+ callback ( null , node )
232+ } )
211233 } )
212234 } ) ,
213235 patch : {
You can’t perform that action at this time.
0 commit comments