forked from filecoin-project/lotus
-
Notifications
You must be signed in to change notification settings - Fork 14
/
garbage.go
46 lines (37 loc) · 1.18 KB
/
garbage.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package sealing
import (
"context"
"golang.org/x/xerrors"
"github.com/filecoin-project/specs-storage/storage"
)
func (m *Sealing) PledgeSector(ctx context.Context) (storage.SectorRef, error) {
m.inputLk.Lock()
defer m.inputLk.Unlock()
cfg, err := m.getConfig()
if err != nil {
return storage.SectorRef{}, xerrors.Errorf("getting config: %w", err)
}
if cfg.MaxSealingSectors > 0 {
if m.stats.curSealing() >= cfg.MaxSealingSectors {
return storage.SectorRef{}, xerrors.Errorf("too many sectors sealing (curSealing: %d, max: %d)", m.stats.curSealing(), cfg.MaxSealingSectors)
}
}
spt, err := m.currentSealProof(ctx)
if err != nil {
return storage.SectorRef{}, xerrors.Errorf("getting seal proof type: %w", err)
}
sid, err := m.sc.Next()
if err != nil {
return storage.SectorRef{}, xerrors.Errorf("generating sector number: %w", err)
}
sectorID := m.minerSector(spt, sid)
err = m.sealer.NewSector(ctx, sectorID)
if err != nil {
return storage.SectorRef{}, xerrors.Errorf("notifying sealer of the new sector: %w", err)
}
log.Infof("Creating CC sector %d", sid)
return sectorID, m.sectors.Send(uint64(sid), SectorStartCC{
ID: sid,
SectorType: spt,
})
}