Add a state for waiting on deals, and events for new deals and start packing

This commit is contained in:
Aayush Rajasekaran 2020-06-23 15:59:57 -04:00
parent db863a4de7
commit eb17b2f371
4 changed files with 24 additions and 1 deletions

7
fsm.go
View File

@ -35,9 +35,14 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto
// Sealing
UndefinedSectorState: planOne(
on(SectorStart{}, Packing),
on(SectorStart{}, Empty),
on(SectorStartCC{}, Packing),
),
Empty: planOne(on(SectorAddPiece{}, WaitDeals)),
WaitDeals: planOne(
on(SectorAddPiece{}, WaitDeals),
on(SectorStartPacking{}, Packing),
),
Packing: planOne(on(SectorPacked{}, PreCommit1)),
PreCommit1: planOne(
on(SectorPreCommit1{}, PreCommit2),

View File

@ -71,6 +71,18 @@ func (evt SectorStartCC) apply(state *SectorInfo) {
state.SectorType = evt.SectorType
}
type SectorAddPiece struct {
NewPiece Piece
}
func (evt SectorAddPiece) apply(state *SectorInfo) {
state.Pieces = append(state.Pieces, evt.NewPiece)
}
type SectorStartPacking struct{}
func (evt SectorStartPacking) apply(*SectorInfo) {}
type SectorPacked struct{ FillerPieces []abi.PieceInfo }
func (evt SectorPacked) apply(state *SectorInfo) {

View File

@ -134,6 +134,11 @@ func (m *Sealing) Remove(ctx context.Context, sid abi.SectorNumber) error {
return m.sectors.Send(uint64(sid), SectorRemove{})
}
func (m *Sealing) StartPacking(sectorID abi.SectorNumber) error {
log.Infof("Starting packing sector %d", sectorID)
return m.sectors.Send(uint64(sectorID), SectorStartPacking{})
}
// newSector accepts a slice of pieces which will have deals associated with
func (m *Sealing) newSector(sid abi.SectorNumber, rt abi.RegisteredSealProof, pieces []Piece) error {
log.Infof("Creating sector %d", sid)

View File

@ -7,6 +7,7 @@ const (
// happy path
Empty SectorState = "Empty"
WaitDeals SectorState = "WaitDeals" // waiting for more pieces (deals) to be added to the sector
Packing SectorState = "Packing" // sector not in sealStore, and not on chain
PreCommit1 SectorState = "PreCommit1" // do PreCommit1
PreCommit2 SectorState = "PreCommit2" // do PreCommit1