Skip to content

Commit

Permalink
some cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
whyrusleeping committed Nov 1, 2019
1 parent a13dfcf commit 2fe1b5a
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions storage/sealing.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ package storage

import (
"context"

"github.com/filecoin-project/lotus/api"
"github.com/filecoin-project/lotus/chain/types"
cid "github.com/ipfs/go-cid"
xerrors "golang.org/x/xerrors"
)

type SealTicket struct {
Expand Down Expand Up @@ -67,9 +69,13 @@ func (m *Miner) onSectorIncoming(sector *SectorInfo) {
}

go func() {
m.sectorUpdated <- sectorUpdate{
select {
case m.sectorUpdated <- sectorUpdate{
newState: api.Unsealed,
id: sector.SectorID,
}:
case <-m.stop:
log.Warn("failed to send incoming sector update, miner shutting down")
}
}()
}
Expand Down Expand Up @@ -109,13 +115,14 @@ func (m *Miner) failSector(id uint64, err error) {
}

func (m *Miner) SealSector(ctx context.Context, sid uint64) error {
select {
case m.sectorIncoming <- &SectorInfo{
si := &SectorInfo{
State: api.UndefinedSectorState,
SectorID: sid,
}:
}
select {
case m.sectorIncoming <- si:
return nil
case <-ctx.Done():
return ctx.Err()
return xerrors.Errorf("failed to submit sector for sealing, queue full: %w", ctx.Err())
}
}

0 comments on commit 2fe1b5a

Please sign in to comment.