sealing: FinalizeSector step
This commit is contained in:
parent
73839692d9
commit
4ce9d005dd
8
fsm.go
8
fsm.go
@ -48,10 +48,14 @@ var fsmPlanners = []func(events []statemachine.Event, state *SectorInfo) error{
|
||||
),
|
||||
api.Committing: planCommitting,
|
||||
api.CommitWait: planOne(
|
||||
on(SectorProving{}, api.Proving),
|
||||
on(SectorProving{}, api.FinalizeSector),
|
||||
on(SectorCommitFailed{}, api.CommitFailed),
|
||||
),
|
||||
|
||||
api.FinalizeSector: planOne(
|
||||
on(SectorFinalized{}, api.Proving),
|
||||
),
|
||||
|
||||
api.Proving: planOne(
|
||||
on(SectorFaultReported{}, api.FaultReported),
|
||||
on(SectorFaulty{}, api.Faulty),
|
||||
@ -150,6 +154,8 @@ func (m *Sealing) plan(events []statemachine.Event, state *SectorInfo) (func(sta
|
||||
return m.handleCommitting, nil
|
||||
case api.CommitWait:
|
||||
return m.handleCommitWait, nil
|
||||
case api.FinalizeSector:
|
||||
|
||||
case api.Proving:
|
||||
// TODO: track sector health / expiration
|
||||
log.Infof("Proving sector %d", state.SectorID)
|
||||
|
@ -120,6 +120,14 @@ type SectorProving struct{}
|
||||
|
||||
func (evt SectorProving) apply(*SectorInfo) {}
|
||||
|
||||
type SectorFinalized struct{}
|
||||
|
||||
func (evt SectorFinalized) apply(*SectorInfo) {}
|
||||
|
||||
type SectorFinalizeFailed struct{ error }
|
||||
|
||||
func (evt SectorFinalizeFailed) apply(*SectorInfo) {}
|
||||
|
||||
// Failed state recovery
|
||||
|
||||
type SectorRetrySeal struct{}
|
||||
|
@ -232,6 +232,14 @@ func (m *Sealing) handleCommitWait(ctx statemachine.Context, sector SectorInfo)
|
||||
return ctx.Send(SectorProving{})
|
||||
}
|
||||
|
||||
func (m *Sealing) handleFinalizeSector(ctx statemachine.Context, sector SectorInfo) error {
|
||||
if err := m.sb.FinalizeSector(ctx.Context(), sector.SectorID); err != nil {
|
||||
return ctx.Send(SectorCommitFailed{err})
|
||||
}
|
||||
|
||||
return ctx.Send(SectorFinalized{})
|
||||
}
|
||||
|
||||
func (m *Sealing) handleFaulty(ctx statemachine.Context, sector SectorInfo) error {
|
||||
// TODO: check if the fault has already been reported, and that this sector is even valid
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user