@@ -6,6 +6,12 @@ const loadFixture = require('aegir/fixtures')
6
6
const CID = require ( 'cids' )
7
7
const all = require ( 'it-all' )
8
8
9
+ const dagPB = require ( 'ipld-dag-pb' )
10
+ const DAGNode = dagPB . DAGNode
11
+ const DAGLink = dagPB . DAGLink
12
+
13
+ const UnixFS = require ( 'ipfs-unixfs' )
14
+
9
15
/** @typedef { import("ipfsd-ctl/src/factory") } Factory */
10
16
/**
11
17
* @param {Factory } common
@@ -307,21 +313,27 @@ function getRefsTests () {
307
313
308
314
function loadPbContent ( ipfs , node ) {
309
315
const store = {
310
- putData : ( data ) => ipfs . object . put ( { Data : data , Links : [ ] } ) ,
311
- putLinks : ( links ) =>
312
- ipfs . object . put ( {
313
- Data : '' ,
314
- Links : links . map ( ( { name, cid } ) => ( { Name : name , Hash : cid , Size : 8 } ) )
315
- } )
316
+ putData : async ( data ) => {
317
+ const res = await ipfs . block . put ( new DAGNode ( data ) . serialize ( ) )
318
+ return res . cid
319
+ } ,
320
+ putLinks : async ( links ) => {
321
+ const res = await ipfs . block . put ( new DAGNode ( '' , links . map ( ( { name, cid } ) => {
322
+ return new DAGLink ( name , 8 , cid )
323
+ } ) ) . serialize ( ) )
324
+ return res . cid
325
+ }
316
326
}
317
327
return loadContent ( ipfs , store , node )
318
328
}
319
329
320
330
function loadDagContent ( ipfs , node ) {
321
331
const store = {
322
332
putData : async ( data ) => {
323
- const res = await all ( ipfs . add ( data ) )
324
- return res [ 0 ] . cid
333
+ const inner = new UnixFS ( { type : 'file' , data : data } )
334
+ const serialized = new DAGNode ( inner . marshal ( ) ) . serialize ( )
335
+ const res = await ipfs . block . put ( serialized )
336
+ return res . cid
325
337
} ,
326
338
putLinks : ( links ) => {
327
339
const obj = { }
0 commit comments