From 6a7d72c030435523cabc7b3b775ecc92c39d4088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Tue, 18 Aug 2020 19:26:17 +0200 Subject: [PATCH] fsm: fail early on too-many-sealing-sectors in pledge --- extern/storage-sealing/garbage.go | 11 +++++++++++ extern/storage-sealing/sealing.go | 11 ----------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/extern/storage-sealing/garbage.go b/extern/storage-sealing/garbage.go index d8cdb4248..4b95c1b67 100644 --- a/extern/storage-sealing/garbage.go +++ b/extern/storage-sealing/garbage.go @@ -31,6 +31,17 @@ func (m *Sealing) pledgeSector(ctx context.Context, sectorID abi.SectorID, exist } 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() { 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 diff --git a/extern/storage-sealing/sealing.go b/extern/storage-sealing/sealing.go index 43c8973db..d52f2d731 100644 --- a/extern/storage-sealing/sealing.go +++ b/extern/storage-sealing/sealing.go @@ -361,17 +361,6 @@ func (m *Sealing) newDealSector() (abi.SectorNumber, error) { // newSectorCC accepts a slice of pieces with no deal (junk data) 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()) if err != nil { return xerrors.Errorf("bad sector size: %w", err)