@@ -242,9 +242,7 @@ func (t *trieView) calculateNodeIDs(ctx context.Context) error {
242
242
// [eg] limits the number of goroutines we start.
243
243
var eg errgroup.Group
244
244
eg .SetLimit (t .db .rootGenConcurrency )
245
- if err = t .calculateNodeIDsHelper (ctx , t .root , & eg ); err != nil {
246
- return
247
- }
245
+ t .calculateNodeIDsHelper (ctx , t .root , & eg )
248
246
if err = eg .Wait (); err != nil {
249
247
return
250
248
}
@@ -261,7 +259,7 @@ func (t *trieView) calculateNodeIDs(ctx context.Context) error {
261
259
262
260
// Calculates the ID of all descendants of [n] which need to be recalculated,
263
261
// and then calculates the ID of [n] itself.
264
- func (t * trieView ) calculateNodeIDsHelper (ctx context.Context , n * node , eg * errgroup.Group ) error {
262
+ func (t * trieView ) calculateNodeIDsHelper (ctx context.Context , n * node , eg * errgroup.Group ) {
265
263
var (
266
264
// We use [wg] to wait until all descendants of [n] have been updated.
267
265
// Note we can't wait on [eg] because [eg] may have started goroutines
@@ -281,24 +279,22 @@ func (t *trieView) calculateNodeIDsHelper(ctx context.Context, n *node, eg *errg
281
279
}
282
280
283
281
wg .Add (1 )
284
- updateChild := func () error {
282
+ updateChild := func () {
285
283
defer wg .Done ()
286
284
287
- if err := t .calculateNodeIDsHelper (ctx , childNodeChange .after , eg ); err != nil {
288
- return err
289
- }
285
+ t .calculateNodeIDsHelper (ctx , childNodeChange .after , eg )
290
286
291
287
// Note that this will never block
292
288
updatedChildren <- childNodeChange .after
293
- return nil
294
289
}
295
290
296
291
// Try updating the child and its descendants in a goroutine.
297
- if ok := eg .TryGo (updateChild ); ! ok {
292
+ if ok := eg .TryGo (func () error {
293
+ updateChild ()
294
+ return nil
295
+ }); ! ok {
298
296
// We're at the goroutine limit; do the work in this goroutine.
299
- if err := updateChild (); err != nil {
300
- return err
301
- }
297
+ updateChild ()
302
298
}
303
299
}
304
300
@@ -311,7 +307,7 @@ func (t *trieView) calculateNodeIDsHelper(ctx context.Context, n *node, eg *errg
311
307
}
312
308
313
309
// The IDs [n]'s descendants are up to date so we can calculate [n]'s ID.
314
- return n .calculateID (t .db .metrics )
310
+ n .calculateID (t .db .metrics )
315
311
}
316
312
317
313
// GetProof returns a proof that [bytesPath] is in or not in trie [t].
0 commit comments