lotus/miner/testminer.go
2019-11-24 22:45:13 -06:00

29 lines
476 B
Go

package miner
import (
"context"
"github.com/filecoin-project/lotus/api"
)
func NewTestMiner(nextCh <-chan struct{}) func(api api.FullNode) *Miner {
return func(api api.FullNode) *Miner {
return &Miner{
api: api,
waitFunc: chanWaiter(nextCh),
}
}
}
func chanWaiter(next <-chan struct{}) func(ctx context.Context) error {
return func(ctx context.Context) error {
select {
case <-ctx.Done():
return ctx.Err()
case <-next:
}
return nil
}
}