lotus/storage/pipeline/garbage.go

44 lines
1.0 KiB
Go
Raw Normal View History

package sealing
import (
"context"
"golang.org/x/xerrors"
"github.com/filecoin-project/lotus/storage/sealer/storiface"
2020-02-27 00:54:39 +00:00
)
func (m *Sealing) PledgeSector(ctx context.Context) (storiface.SectorRef, error) {
2021-06-15 19:04:11 +00:00
m.startupWait.Wait()
2021-02-16 16:14:59 +00:00
m.inputLk.Lock()
defer m.inputLk.Unlock()
cfg, err := m.getConfig()
if err != nil {
return storiface.SectorRef{}, xerrors.Errorf("getting config: %w", err)
}
if cfg.MaxSealingSectors > 0 {
if m.stats.curSealing() >= cfg.MaxSealingSectors {
return storiface.SectorRef{}, xerrors.Errorf("too many sectors sealing (curSealing: %d, max: %d)", m.stats.curSealing(), cfg.MaxSealingSectors)
}
}
2021-02-16 16:14:59 +00:00
spt, err := m.currentSealProof(ctx)
if err != nil {
return storiface.SectorRef{}, xerrors.Errorf("getting seal proof type: %w", err)
2021-02-16 16:14:59 +00:00
}
2021-03-12 17:42:17 +00:00
sid, err := m.createSector(ctx, cfg, spt)
2021-02-16 16:14:59 +00:00
if err != nil {
return storiface.SectorRef{}, err
2021-02-16 16:14:59 +00:00
}
2021-02-16 16:14:59 +00:00
log.Infof("Creating CC sector %d", sid)
2021-03-12 17:42:17 +00:00
return m.minerSector(spt, sid), m.sectors.Send(uint64(sid), SectorStartCC{
2021-02-16 16:14:59 +00:00
ID: sid,
SectorType: spt,
})
}