pass context to WriteStateSnapshot
Some checks failed
Test / Run integration tests (pull_request) Failing after 0s
Test / Run compliance tests (pull_request) Failing after 0s
Test / Run unit tests (pull_request) Successful in 9m49s

this allows canceling the workers
This commit is contained in:
Roy Crihfield 2023-10-06 14:45:42 +08:00
parent 285a0ac2d2
commit 353d0ce688
2 changed files with 4 additions and 1 deletions

View File

@ -168,6 +168,7 @@ func (sdb *builder) WriteStateDiff(
// WriteStateDiff writes a statediff object to output sinks // WriteStateDiff writes a statediff object to output sinks
func (sdb *builder) WriteStateSnapshot( func (sdb *builder) WriteStateSnapshot(
ctx context.Context,
stateRoot common.Hash, params Params, stateRoot common.Hash, params Params,
nodeSink sdtypes.StateNodeSink, nodeSink sdtypes.StateNodeSink,
ipldSink sdtypes.IPLDSink, ipldSink sdtypes.IPLDSink,
@ -200,7 +201,7 @@ func (sdb *builder) WriteStateSnapshot(
} }
} }
// errgroup will cancel if any group fails // errgroup will cancel if any group fails
g, ctx := errgroup.WithContext(context.Background()) g, ctx := errgroup.WithContext(ctx)
for i := range subiters { for i := range subiters {
func(subdiv uint) { func(subdiv uint) {
g.Go(func() error { g.Go(func() error {

View File

@ -2,6 +2,7 @@ package test_helpers
import ( import (
"bytes" "bytes"
"context"
"fmt" "fmt"
"math/big" "math/big"
"math/rand" "math/rand"
@ -93,6 +94,7 @@ func RunStateSnapshot(
tr := tracker.New(recoveryFile, subtries) tr := tracker.New(recoveryFile, subtries)
defer tr.CloseAndSave() defer tr.CloseAndSave()
return builder.WriteStateSnapshot( return builder.WriteStateSnapshot(
context.Background(),
test.StateRoot, params, stateAppender, ipldAppender, tr, test.StateRoot, params, stateAppender, ipldAppender, tr,
) )
} }