Add new event for start of CC sectors
This commit is contained in:
parent
5ad33896cc
commit
db863a4de7
7
fsm.go
7
fsm.go
@ -34,8 +34,11 @@ func (m *Sealing) Plan(events []statemachine.Event, user interface{}) (interface
|
||||
var fsmPlanners = map[SectorState]func(events []statemachine.Event, state *SectorInfo) error{
|
||||
// Sealing
|
||||
|
||||
UndefinedSectorState: planOne(on(SectorStart{}, Packing)),
|
||||
Packing: planOne(on(SectorPacked{}, PreCommit1)),
|
||||
UndefinedSectorState: planOne(
|
||||
on(SectorStart{}, Packing),
|
||||
on(SectorStartCC{}, Packing),
|
||||
),
|
||||
Packing: planOne(on(SectorPacked{}, PreCommit1)),
|
||||
PreCommit1: planOne(
|
||||
on(SectorPreCommit1{}, PreCommit2),
|
||||
on(SectorSealPreCommit1Failed{}, SealPreCommit1Failed),
|
||||
|
@ -59,6 +59,18 @@ func (evt SectorStart) apply(state *SectorInfo) {
|
||||
state.SectorType = evt.SectorType
|
||||
}
|
||||
|
||||
type SectorStartCC struct {
|
||||
ID abi.SectorNumber
|
||||
SectorType abi.RegisteredSealProof
|
||||
Pieces []Piece
|
||||
}
|
||||
|
||||
func (evt SectorStartCC) apply(state *SectorInfo) {
|
||||
state.SectorNumber = evt.ID
|
||||
state.Pieces = evt.Pieces
|
||||
state.SectorType = evt.SectorType
|
||||
}
|
||||
|
||||
type SectorPacked struct{ FillerPieces []abi.PieceInfo }
|
||||
|
||||
func (evt SectorPacked) apply(state *SectorInfo) {
|
||||
|
@ -77,7 +77,7 @@ func (m *Sealing) PledgeSector() error {
|
||||
}
|
||||
}
|
||||
|
||||
if err := m.newSector(sid, rt, ps); err != nil {
|
||||
if err := m.newSectorCC(sid, rt, ps); err != nil {
|
||||
log.Errorf("%+v", err)
|
||||
return
|
||||
}
|
||||
|
22
sealing.go
22
sealing.go
@ -90,7 +90,7 @@ func (m *Sealing) AllocatePiece(size abi.UnpaddedPieceSize) (sectorID abi.Sector
|
||||
if (padreader.PaddedSize(uint64(size))) != size {
|
||||
return 0, 0, xerrors.Errorf("cannot allocate unpadded piece")
|
||||
}
|
||||
|
||||
|
||||
if size > abi.UnpaddedPieceSize(m.sealer.SectorSize()) {
|
||||
return 0, 0, xerrors.Errorf("piece cannot fit into a sector")
|
||||
}
|
||||
@ -130,11 +130,13 @@ func (m *Sealing) SealPiece(ctx context.Context, size abi.UnpaddedPieceSize, r i
|
||||
})
|
||||
}
|
||||
|
||||
// newSector accepts a slice of pieces which will have a deal associated with
|
||||
// them (in the event of a storage deal) or no deal (in the event of sealing
|
||||
// garbage data)
|
||||
func (m *Sealing) Remove(ctx context.Context, sid abi.SectorNumber) error {
|
||||
return m.sectors.Send(uint64(sid), SectorRemove{})
|
||||
}
|
||||
|
||||
// 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("Start sealing %d", sid)
|
||||
log.Infof("Creating sector %d", sid)
|
||||
return m.sectors.Send(uint64(sid), SectorStart{
|
||||
ID: sid,
|
||||
Pieces: pieces,
|
||||
@ -142,8 +144,14 @@ func (m *Sealing) newSector(sid abi.SectorNumber, rt abi.RegisteredSealProof, pi
|
||||
})
|
||||
}
|
||||
|
||||
func (m *Sealing) Remove(ctx context.Context, sid abi.SectorNumber) error {
|
||||
return m.sectors.Send(uint64(sid), SectorRemove{})
|
||||
// newSectorCC accepts a slice of pieces with no deal (junk data)
|
||||
func (m *Sealing) newSectorCC(sid abi.SectorNumber, rt abi.RegisteredSealProof, pieces []Piece) error {
|
||||
log.Infof("Creating CC sector %d", sid)
|
||||
return m.sectors.Send(uint64(sid), SectorStartCC{
|
||||
ID: sid,
|
||||
Pieces: pieces,
|
||||
SectorType: rt,
|
||||
})
|
||||
}
|
||||
|
||||
func (m *Sealing) minerSector(num abi.SectorNumber) abi.SectorID {
|
||||
|
Loading…
Reference in New Issue
Block a user