lotus/miner/testminer.go

27 lines
416 B
Go
Raw Normal View History

2019-09-23 15:27:30 +00:00
package miner
import (
"context"
)
func NewTestMiner(nextCh <-chan struct{}) func(api api) *Miner {
return func(api api) *Miner {
return &Miner{
2019-10-09 04:38:59 +00:00
api: api,
waitFunc: chanWaiter(nextCh),
2019-09-23 15:27:30 +00:00
}
}
}
2019-10-09 04:38:59 +00:00
func chanWaiter(next <-chan struct{}) func(ctx context.Context) error {
return func(ctx context.Context) error {
2019-09-23 15:27:30 +00:00
select {
case <-ctx.Done():
2019-10-09 04:38:59 +00:00
return ctx.Err()
2019-09-23 15:27:30 +00:00
case <-next:
}
2019-10-09 04:38:59 +00:00
return nil
2019-09-23 15:27:30 +00:00
}
}