1
1
'use strict'
2
2
3
3
const {
4
- DAGLink ,
5
- DAGNode
6
- } = require ( 'ipld- dag-pb' )
4
+ encode ,
5
+ prepare
6
+ } = require ( '@ ipld/ dag-pb' )
7
7
const UnixFS = require ( 'ipfs-unixfs' )
8
8
const multihashing = require ( 'multihashing-async' )
9
9
const Dir = require ( './dir' )
@@ -110,7 +110,11 @@ async function * flush (path, bucket, block, shardRoot, options) {
110
110
shard = subShard
111
111
}
112
112
113
- links . push ( new DAGLink ( labelPrefix , shard . size , shard . cid ) )
113
+ links . push ( {
114
+ Name : labelPrefix ,
115
+ Tsize : shard . size ,
116
+ Hash : shard . cid
117
+ } )
114
118
childrenSize += shard . size
115
119
} else if ( typeof child . value . flush === 'function' ) {
116
120
const dir = child . value
@@ -123,7 +127,11 @@ async function * flush (path, bucket, block, shardRoot, options) {
123
127
}
124
128
125
129
const label = labelPrefix + child . key
126
- links . push ( new DAGLink ( label , flushedDir . size , flushedDir . cid ) )
130
+ links . push ( {
131
+ Name : label ,
132
+ Tsize : flushedDir . size ,
133
+ Hash : flushedDir . cid
134
+ } )
127
135
128
136
childrenSize += flushedDir . size
129
137
} else {
@@ -136,7 +144,11 @@ async function * flush (path, bucket, block, shardRoot, options) {
136
144
const label = labelPrefix + child . key
137
145
const size = value . size
138
146
139
- links . push ( new DAGLink ( label , size , value . cid ) )
147
+ links . push ( {
148
+ Name : label ,
149
+ Tsize : size ,
150
+ Hash : value . cid
151
+ } )
140
152
childrenSize += size
141
153
}
142
154
}
@@ -153,8 +165,11 @@ async function * flush (path, bucket, block, shardRoot, options) {
153
165
mode : shardRoot && shardRoot . mode
154
166
} )
155
167
156
- const node = new DAGNode ( dir . marshal ( ) , links )
157
- const buffer = node . serialize ( )
168
+ const node = {
169
+ Data : dir . marshal ( ) ,
170
+ Links : links
171
+ }
172
+ const buffer = encode ( prepare ( node ) )
158
173
const cid = await persist ( buffer , block , options )
159
174
const size = buffer . length + childrenSize
160
175
0 commit comments