fix mining termination race condition
This commit is contained in:
parent
3d5f58c8b8
commit
b7403fd93c
@ -38,7 +38,8 @@ func runMiner(t *TestEnvironment) error {
|
|||||||
done := make(chan struct{})
|
done := make(chan struct{})
|
||||||
go func() {
|
go func() {
|
||||||
defer close(done)
|
defer close(done)
|
||||||
for i := 0; mine; i++ {
|
var i int
|
||||||
|
for i = 0; mine; i++ {
|
||||||
|
|
||||||
// synchronize all miners to mine the next block
|
// synchronize all miners to mine the next block
|
||||||
t.RecordMessage("synchronizing all miners to mine next block [%d]", i)
|
t.RecordMessage("synchronizing all miners to mine next block [%d]", i)
|
||||||
@ -55,6 +56,11 @@ func runMiner(t *TestEnvironment) error {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// signal the last block to make sure no miners are left stuck waiting for the next block signal
|
||||||
|
// while the others have stopped
|
||||||
|
stateMineLast := sync.State(fmt.Sprintf("mine-block-%d", i))
|
||||||
|
t.SyncClient.MustSignalEntry(ctx, stateMineLast)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
// wait for a signal from all clients to stop mining
|
// wait for a signal from all clients to stop mining
|
||||||
|
Loading…
Reference in New Issue
Block a user