storage: Fix handing stop call

This commit is contained in:
Łukasz Magiera 2020-01-23 10:46:46 +01:00
parent e43174f2af
commit 7fb3360d6f

View File

@ -36,9 +36,6 @@ type Miner struct {
worker address.Address worker address.Address
sealing *sealing.Sealing sealing *sealing.Sealing
stop chan struct{}
stopped chan struct{}
} }
type storageMinerApi interface { type storageMinerApi interface {
@ -76,9 +73,6 @@ func NewMiner(api storageMinerApi, addr address.Address, h host.Host, ds datasto
tktFn: tktFn, tktFn: tktFn,
maddr: addr, maddr: addr,
stop: make(chan struct{}),
stopped: make(chan struct{}),
} }
return m, nil return m, nil
@ -109,14 +103,7 @@ func (m *Miner) Run(ctx context.Context) error {
func (m *Miner) Stop(ctx context.Context) error { func (m *Miner) Stop(ctx context.Context) error {
defer m.sealing.Stop(ctx) defer m.sealing.Stop(ctx)
return nil
close(m.stop)
select {
case <-m.stopped:
return nil
case <-ctx.Done():
return ctx.Err()
}
} }
func (m *Miner) runPreflightChecks(ctx context.Context) error { func (m *Miner) runPreflightChecks(ctx context.Context) error {