@@ -65,7 +65,6 @@ exports = module.exports = function (dag) {
65
65
hasChild : ( root , childhash , callback , _links , _checked , _seen ) => {
66
66
// callback (err, has)
67
67
callback = once ( callback )
68
- if ( callback . called ) { return }
69
68
if ( typeof childhash === 'object' ) {
70
69
childhash = toB58String ( childhash )
71
70
}
@@ -83,9 +82,7 @@ exports = module.exports = function (dag) {
83
82
return callback ( null , true )
84
83
}
85
84
dag . get ( new CID ( link . multihash ) , ( err , res ) => {
86
- if ( err ) {
87
- return callback ( err )
88
- }
85
+ if ( err ) { return callback ( err ) }
89
86
// don't check the same links twice
90
87
if ( bs58link in _seen ) { return }
91
88
_seen [ bs58link ] = true
@@ -180,15 +177,9 @@ exports = module.exports = function (dag) {
180
177
hashed [ h ] . push ( items [ i ] )
181
178
}
182
179
const storeItemsCb = ( err , child ) => {
183
- if ( callback . called ) { return }
184
- if ( err ) {
185
- return callback ( err )
186
- }
180
+ if ( err ) { return callback ( err ) }
187
181
dag . put ( child , ( err ) => {
188
- if ( callback . called ) { return }
189
- if ( err ) {
190
- return callback ( err )
191
- }
182
+ if ( err ) { return callback ( err ) }
192
183
logInternalKey ( child . multihash )
193
184
rootLinks [ this . h ] = new DAGLink (
194
185
'' , child . size , child . multihash
@@ -203,19 +194,18 @@ exports = module.exports = function (dag) {
203
194
}
204
195
} )
205
196
}
206
- _subcalls += Object . keys ( hashed ) . length
207
- for ( let h in hashed ) {
208
- if ( hashed . hasOwnProperty ( h ) ) {
209
- pinSet . storeItems (
210
- hashed [ h ] ,
211
- logInternalKey ,
212
- storeItemsCb . bind ( { h : h } ) ,
213
- _depth + 1 ,
214
- _subcalls ,
215
- _done
216
- )
217
- }
218
- }
197
+ const hashedKeys = Object . keys ( hashed )
198
+ _subcalls += hashedKeys . length
199
+ hashedKeys . forEach ( h => {
200
+ pinSet . storeItems (
201
+ hashed [ h ] ,
202
+ logInternalKey ,
203
+ storeItemsCb . bind ( { h : h } ) ,
204
+ _depth + 1 ,
205
+ _subcalls ,
206
+ _done
207
+ )
208
+ } )
219
209
}
220
210
} ,
221
211
0 commit comments