diff --git a/fsm.go b/fsm.go index 4e48be15e..2355c68bd 100644 --- a/fsm.go +++ b/fsm.go @@ -155,7 +155,7 @@ func (m *Sealing) plan(events []statemachine.Event, state *SectorInfo) (func(sta case api.CommitWait: return m.handleCommitWait, nil case api.FinalizeSector: - + return m.handleFinalizeSector, nil case api.Proving: // TODO: track sector health / expiration log.Infof("Proving sector %d", state.SectorID) diff --git a/states.go b/states.go index 22a7f642b..5d70533bc 100644 --- a/states.go +++ b/states.go @@ -233,8 +233,14 @@ func (m *Sealing) handleCommitWait(ctx statemachine.Context, sector SectorInfo) } func (m *Sealing) handleFinalizeSector(ctx statemachine.Context, sector SectorInfo) error { + // TODO: Maybe wait for some finality + if err := m.sb.FinalizeSector(ctx.Context(), sector.SectorID); err != nil { - return ctx.Send(SectorCommitFailed{err}) + return ctx.Send(SectorCommitFailed{xerrors.Errorf("finalize sector: %w", err)}) + } + + if err := m.sb.DropStaged(ctx.Context(), sector.SectorID); err != nil { + return ctx.Send(SectorCommitFailed{xerrors.Errorf("drop staged: %w", err)}) } return ctx.Send(SectorFinalized{})