pass context to WriteStateSnapshot
this allows canceling the workers
This commit is contained in:
parent
285a0ac2d2
commit
353d0ce688
@ -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 {
|
||||||
|
@ -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,
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user