sealing: Run more checks when considering Available sectors

This commit is contained in:
Łukasz Magiera 2022-03-16 19:57:37 +01:00
parent 4d4739497d
commit e7ee5b5932
2 changed files with 13 additions and 5 deletions

View File

@ -570,6 +570,16 @@ func (m *Sealing) tryGetUpgradeSector(ctx context.Context, sp abi.RegisteredSeal
continue
}
active, err := m.sectorActive(ctx, TipSetToken{}, s.Number)
if err != nil {
log.Errorw("checking sector active", "error", err)
continue
}
if !active {
log.Debugw("skipping available sector", "reason", "not active")
continue
}
// if best is below target, we want larger expirations
// if best is above target, we want lower pledge, but only if still above target

View File

@ -2,8 +2,6 @@ package sealing
import (
"context"
"github.com/filecoin-project/go-address"
market7 "github.com/filecoin-project/specs-actors/v7/actors/builtin/market"
"golang.org/x/xerrors"
@ -34,7 +32,7 @@ func (m *Sealing) MarkForSnapUpgrade(ctx context.Context, id abi.SectorNumber) e
return xerrors.Errorf("failed to read sector on chain info: %w", err)
}
active, err := sectorActive(ctx, m.Api, m.maddr, tok, id)
active, err := m.sectorActive(ctx, tok, id)
if err != nil {
return xerrors.Errorf("failed to check if sector is active")
}
@ -50,8 +48,8 @@ func (m *Sealing) MarkForSnapUpgrade(ctx context.Context, id abi.SectorNumber) e
return m.sectors.Send(uint64(id), SectorMarkForUpdate{})
}
func sectorActive(ctx context.Context, api SealingAPI, maddr address.Address, tok TipSetToken, sector abi.SectorNumber) (bool, error) {
active, err := api.StateMinerActiveSectors(ctx, maddr, tok)
func (m *Sealing) sectorActive(ctx context.Context, tok TipSetToken, sector abi.SectorNumber) (bool, error) {
active, err := m.Api.StateMinerActiveSectors(ctx, m.maddr, tok)
if err != nil {
return false, xerrors.Errorf("failed to check active sectors: %w", err)
}