storageminer: exit PledgeSector after sectors enter sealing pipeline
This commit is contained in:
parent
46b880a6b9
commit
f719765069
16
extern/storage-sealing/garbage.go
vendored
16
extern/storage-sealing/garbage.go
vendored
@ -4,40 +4,42 @@ import (
|
||||
"context"
|
||||
|
||||
"golang.org/x/xerrors"
|
||||
|
||||
"github.com/filecoin-project/specs-storage/storage"
|
||||
)
|
||||
|
||||
func (m *Sealing) PledgeSector(ctx context.Context) error {
|
||||
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 xerrors.Errorf("getting config: %w", err)
|
||||
return storage.SectorRef{}, 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)
|
||||
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 xerrors.Errorf("getting seal proof type: %w", err)
|
||||
return storage.SectorRef{}, xerrors.Errorf("getting seal proof type: %w", err)
|
||||
}
|
||||
|
||||
sid, err := m.sc.Next()
|
||||
if err != nil {
|
||||
return xerrors.Errorf("generating sector number: %w", err)
|
||||
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 xerrors.Errorf("notifying sealer of the new sector: %w", err)
|
||||
return storage.SectorRef{}, xerrors.Errorf("notifying sealer of the new sector: %w", err)
|
||||
}
|
||||
|
||||
log.Infof("Creating CC sector %d", sid)
|
||||
return m.sectors.Send(uint64(sid), SectorStartCC{
|
||||
return sectorID, m.sectors.Send(uint64(sid), SectorStartCC{
|
||||
ID: sid,
|
||||
SectorType: spt,
|
||||
})
|
||||
|
@ -122,7 +122,29 @@ func (sm *StorageMinerAPI) ActorSectorSize(ctx context.Context, addr address.Add
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) PledgeSector(ctx context.Context) error {
|
||||
return sm.Miner.PledgeSector(ctx)
|
||||
sr, err := sm.Miner.PledgeSector(ctx)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// wait for the sector to enter the Packing state
|
||||
// TODO: instead of polling implement some pubsub-type thing in storagefsm
|
||||
for {
|
||||
info, err := sm.Miner.GetSectorInfo(sr.ID.Number)
|
||||
if err != nil {
|
||||
return xerrors.Errorf("getting pledged sector info: %w", err)
|
||||
}
|
||||
|
||||
if info.State != sealing.UndefinedSectorState {
|
||||
return nil
|
||||
}
|
||||
|
||||
select {
|
||||
case <-time.After(10 * time.Millisecond):
|
||||
case <-ctx.Done():
|
||||
return ctx.Err()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func (sm *StorageMinerAPI) SectorsStatus(ctx context.Context, sid abi.SectorNumber, showOnChainInfo bool) (api.SectorInfo, error) {
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
|
||||
"github.com/filecoin-project/go-address"
|
||||
"github.com/filecoin-project/go-state-types/abi"
|
||||
"github.com/filecoin-project/specs-storage/storage"
|
||||
|
||||
sealing "github.com/filecoin-project/lotus/extern/storage-sealing"
|
||||
)
|
||||
@ -34,7 +35,7 @@ func (m *Miner) GetSectorInfo(sid abi.SectorNumber) (sealing.SectorInfo, error)
|
||||
return m.sealing.GetSectorInfo(sid)
|
||||
}
|
||||
|
||||
func (m *Miner) PledgeSector(ctx context.Context) error {
|
||||
func (m *Miner) PledgeSector(ctx context.Context) (storage.SectorRef, error) {
|
||||
return m.sealing.PledgeSector(ctx)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user