sealing: Errors are hard

This commit is contained in:
Łukasz Magiera 2020-01-23 17:02:55 +01:00
parent 82343460dd
commit 54289225e8

View File

@ -46,12 +46,12 @@ func (m *Sealing) handlePacking(ctx statemachine.Context, sector SectorInfo) err
func (m *Sealing) handleUnsealed(ctx statemachine.Context, sector SectorInfo) error { func (m *Sealing) handleUnsealed(ctx statemachine.Context, sector SectorInfo) error {
if err := checkPieces(ctx.Context(), sector, m.api); err != nil { // Sanity check state if err := checkPieces(ctx.Context(), sector, m.api); err != nil { // Sanity check state
switch err.(type) { switch err.(type) {
case ErrApi: case *ErrApi:
log.Errorf("handleUnsealed: api error, not proceeding: %+v", err) log.Errorf("handleUnsealed: api error, not proceeding: %+v", err)
return nil return nil
case ErrInvalidDeals: case *ErrInvalidDeals:
return ctx.Send(SectorPackingFailed{xerrors.Errorf("invalid deals in sector: %w", err)}) return ctx.Send(SectorPackingFailed{xerrors.Errorf("invalid deals in sector: %w", err)})
case ErrExpiredDeals: // Probably not much we can do here, maybe re-pack the sector? case *ErrExpiredDeals: // Probably not much we can do here, maybe re-pack the sector?
return ctx.Send(SectorPackingFailed{xerrors.Errorf("expired deals in sector: %w", err)}) return ctx.Send(SectorPackingFailed{xerrors.Errorf("expired deals in sector: %w", err)})
default: default:
return xerrors.Errorf("checkPieces sanity check error: %w", err) return xerrors.Errorf("checkPieces sanity check error: %w", err)
@ -82,12 +82,12 @@ func (m *Sealing) handleUnsealed(ctx statemachine.Context, sector SectorInfo) er
func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInfo) error { func (m *Sealing) handlePreCommitting(ctx statemachine.Context, sector SectorInfo) error {
if err := checkSeal(ctx.Context(), m.maddr, sector, m.api); err != nil { if err := checkSeal(ctx.Context(), m.maddr, sector, m.api); err != nil {
switch err.(type) { switch err.(type) {
case ErrApi: case *ErrApi:
log.Errorf("handlePreCommitting: api error, not proceeding: %+v", err) log.Errorf("handlePreCommitting: api error, not proceeding: %+v", err)
return nil return nil
case ErrBadCommD: // TODO: Should this just back to packing? (not really needed since handleUnsealed will do that too) case *ErrBadCommD: // TODO: Should this just back to packing? (not really needed since handleUnsealed will do that too)
return ctx.Send(SectorSealFailed{xerrors.Errorf("bad CommD error: %w", err)}) return ctx.Send(SectorSealFailed{xerrors.Errorf("bad CommD error: %w", err)})
case ErrExpiredTicket: case *ErrExpiredTicket:
return ctx.Send(SectorSealFailed{xerrors.Errorf("bad CommD error: %w", err)}) return ctx.Send(SectorSealFailed{xerrors.Errorf("bad CommD error: %w", err)})
default: default:
return xerrors.Errorf("checkSeal sanity check error: %w", err) return xerrors.Errorf("checkSeal sanity check error: %w", err)