Add a state for waiting on deals, and events for new deals and start packing
This commit is contained in:
parent
db863a4de7
commit
eb17b2f371
7
fsm.go
7
fsm.go
@ -35,9 +35,14 @@ var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *Secto
|
|||||||
// Sealing
|
// Sealing
|
||||||
|
|
||||||
UndefinedSectorState: planOne(
|
UndefinedSectorState: planOne(
|
||||||
on(SectorStart{}, Packing),
|
on(SectorStart{}, Empty),
|
||||||
on(SectorStartCC{}, Packing),
|
on(SectorStartCC{}, Packing),
|
||||||
),
|
),
|
||||||
|
Empty: planOne(on(SectorAddPiece{}, WaitDeals)),
|
||||||
|
WaitDeals: planOne(
|
||||||
|
on(SectorAddPiece{}, WaitDeals),
|
||||||
|
on(SectorStartPacking{}, Packing),
|
||||||
|
),
|
||||||
Packing: planOne(on(SectorPacked{}, PreCommit1)),
|
Packing: planOne(on(SectorPacked{}, PreCommit1)),
|
||||||
PreCommit1: planOne(
|
PreCommit1: planOne(
|
||||||
on(SectorPreCommit1{}, PreCommit2),
|
on(SectorPreCommit1{}, PreCommit2),
|
||||||
|
@ -71,6 +71,18 @@ func (evt SectorStartCC) apply(state *SectorInfo) {
|
|||||||
state.SectorType = evt.SectorType
|
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 }
|
type SectorPacked struct{ FillerPieces []abi.PieceInfo }
|
||||||
|
|
||||||
func (evt SectorPacked) apply(state *SectorInfo) {
|
func (evt SectorPacked) apply(state *SectorInfo) {
|
||||||
|
@ -134,6 +134,11 @@ func (m *Sealing) Remove(ctx context.Context, sid abi.SectorNumber) error {
|
|||||||
return m.sectors.Send(uint64(sid), SectorRemove{})
|
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
|
// 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 {
|
func (m *Sealing) newSector(sid abi.SectorNumber, rt abi.RegisteredSealProof, pieces []Piece) error {
|
||||||
log.Infof("Creating sector %d", sid)
|
log.Infof("Creating sector %d", sid)
|
||||||
|
@ -7,6 +7,7 @@ const (
|
|||||||
|
|
||||||
// happy path
|
// happy path
|
||||||
Empty SectorState = "Empty"
|
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
|
Packing SectorState = "Packing" // sector not in sealStore, and not on chain
|
||||||
PreCommit1 SectorState = "PreCommit1" // do PreCommit1
|
PreCommit1 SectorState = "PreCommit1" // do PreCommit1
|
||||||
PreCommit2 SectorState = "PreCommit2" // do PreCommit1
|
PreCommit2 SectorState = "PreCommit2" // do PreCommit1
|
||||||
|
Loading…
Reference in New Issue
Block a user