fsm: fail early on too-many-sealing-sectors in pledge

This commit is contained in:
Łukasz Magiera 2020-08-18 19:26:17 +02:00
parent e7d65be90a
commit 6a7d72c030
2 changed files with 11 additions and 11 deletions

View File

@ -31,6 +31,17 @@ func (m *Sealing) pledgeSector(ctx context.Context, sectorID abi.SectorID, exist
} }
func (m *Sealing) PledgeSector() error { func (m *Sealing) PledgeSector() error {
cfg, err := m.getConfig()
if err != nil {
return xerrors.Errorf("getting config: %w", err)
}
if cfg.MaxSealingSectors > 0 {
if m.stats.curSealing() > cfg.MaxSealingSectors {
return xerrors.Errorf("too many sectors sealing (curSealing: %d, max: %d)", m.stats.curSealing(), cfg.MaxSealingSectors)
}
}
go func() { go func() {
ctx := context.TODO() // we can't use the context from command which invokes ctx := context.TODO() // we can't use the context from command which invokes
// this, as we run everything here async, and it's cancelled when the // this, as we run everything here async, and it's cancelled when the

View File

@ -361,17 +361,6 @@ func (m *Sealing) newDealSector() (abi.SectorNumber, error) {
// newSectorCC accepts a slice of pieces with no deal (junk data) // newSectorCC accepts a slice of pieces with no deal (junk data)
func (m *Sealing) newSectorCC(sid abi.SectorNumber, pieces []Piece) error { func (m *Sealing) newSectorCC(sid abi.SectorNumber, pieces []Piece) error {
cfg, err := m.getConfig()
if err != nil {
return xerrors.Errorf("getting config: %w", err)
}
if cfg.MaxSealingSectors > 0 {
if m.stats.curSealing() > cfg.MaxSealingSectors {
return xerrors.Errorf("too many sectors sealing (curSealing: %d, max: %d)", m.stats.curSealing(), cfg.MaxSealingSectors)
}
}
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)