Non-CC sectors start with no pieces, can be added using addPiece()

This commit is contained in:
Aayush Rajasekaran 2020-06-23 16:51:35 -04:00
parent 7f75cd71da
commit 73f5c68674
2 changed files with 20 additions and 11 deletions

View File

@ -50,12 +50,10 @@ func (evt SectorForceState) applyGlobal(state *SectorInfo) bool {
type SectorStart struct { type SectorStart struct {
ID abi.SectorNumber ID abi.SectorNumber
SectorType abi.RegisteredSealProof SectorType abi.RegisteredSealProof
Pieces []Piece
} }
func (evt SectorStart) apply(state *SectorInfo) { func (evt SectorStart) apply(state *SectorInfo) {
state.SectorNumber = evt.ID state.SectorNumber = evt.ID
state.Pieces = evt.Pieces
state.SectorType = evt.SectorType state.SectorType = evt.SectorType
} }

View File

@ -114,15 +114,27 @@ func (m *Sealing) SealPiece(ctx context.Context, size abi.UnpaddedPieceSize, r i
ppi, err := m.sealer.AddPiece(sectorstorage.WithPriority(ctx, DealSectorPriority), m.minerSector(sectorID), []abi.UnpaddedPieceSize{}, size, r) ppi, err := m.sealer.AddPiece(sectorstorage.WithPriority(ctx, DealSectorPriority), m.minerSector(sectorID), []abi.UnpaddedPieceSize{}, size, r)
if err != nil { if err != nil {
return xerrors.Errorf("adding piece to sector: %w", err) return xerrors.Errorf("writing piece: %w", err)
} }
return m.newSector(sectorID, []Piece{ err = m.newSector(sectorID)
{ if err != nil {
Piece: ppi, return xerrors.Errorf("creating new sector: %w", err)
DealInfo: &d, }
},
err = m.addPiece(sectorID, Piece{
Piece: ppi,
DealInfo: &d,
}) })
if err != nil {
return xerrors.Errorf("adding piece to sector: %w", err)
}
}
func (m *Sealing) addPiece(sectorID abi.SectorNumber, piece Piece) error {
log.Infof("Adding piece to sector %d", sectorID)
return m.sectors.Send(uint64(sectorID), SectorAddPiece{NewPiece: piece})
} }
func (m *Sealing) Remove(ctx context.Context, sid abi.SectorNumber) error { func (m *Sealing) Remove(ctx context.Context, sid abi.SectorNumber) error {
@ -134,8 +146,8 @@ func (m *Sealing) StartPacking(sectorID abi.SectorNumber) error {
return m.sectors.Send(uint64(sectorID), SectorStartPacking{}) return m.sectors.Send(uint64(sectorID), SectorStartPacking{})
} }
// newSector accepts a slice of pieces which will have deals associated with // newSector creates a new sector for deal storage
func (m *Sealing) newSector(sid abi.SectorNumber, pieces []Piece) error { func (m *Sealing) newSector(sid abi.SectorNumber) error {
rt, err := ffiwrapper.SealProofTypeFromSectorSize(m.sealer.SectorSize()) rt, err := ffiwrapper.SealProofTypeFromSectorSize(m.sealer.SectorSize())
if err != nil { if err != nil {
return xerrors.Errorf("bad sector size: %w", err) return xerrors.Errorf("bad sector size: %w", err)
@ -144,7 +156,6 @@ func (m *Sealing) newSector(sid abi.SectorNumber, pieces []Piece) error {
log.Infof("Creating sector %d", sid) log.Infof("Creating sector %d", sid)
return m.sectors.Send(uint64(sid), SectorStart{ return m.sectors.Send(uint64(sid), SectorStart{
ID: sid, ID: sid,
Pieces: pieces,
SectorType: rt, SectorType: rt,
}) })
} }