Skip to content

Commit

Permalink
fix expiration config handling in calcTargetExpiration
Browse files Browse the repository at this point in the history
  • Loading branch information
magik6k committed Sep 16, 2022
1 parent bf3daea commit 4c72691
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions storage/pipeline/input.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,12 +550,13 @@ func (m *Sealing) calcTargetExpiration(ctx context.Context, ssize abi.SectorSize
}
}

ts, err := m.Api.ChainHead(ctx)
if err != nil {
return 0, 0, xerrors.Errorf("getting current epoch: %w", err)
}

// if the sector isn't full, use max deal duration as the target
if !full {
ts, err := m.Api.ChainHead(ctx)
if err != nil {
return 0, 0, xerrors.Errorf("getting current epoch: %w", err)
}

minDur, maxDur := policy.DealDurationBounds(0)
minExp = ts.Height() + minDur
Expand All @@ -569,11 +570,11 @@ func (m *Sealing) calcTargetExpiration(ctx context.Context, ssize abi.SectorSize
}

// apply user minimums
if abi.ChainEpoch(cfg.MinUpgradeSectorExpiration) > minExp {
minExp = abi.ChainEpoch(cfg.MinUpgradeSectorExpiration)
if abi.ChainEpoch(cfg.MinUpgradeSectorExpiration)+ts.Height() > minExp {
minExp = abi.ChainEpoch(cfg.MinUpgradeSectorExpiration) + ts.Height()
}
if abi.ChainEpoch(cfg.MinTargetUpgradeSectorExpiration) > target {
target = abi.ChainEpoch(cfg.MinTargetUpgradeSectorExpiration)
if abi.ChainEpoch(cfg.MinTargetUpgradeSectorExpiration)+ts.Height() > target {
target = abi.ChainEpoch(cfg.MinTargetUpgradeSectorExpiration) + ts.Height()
}

return minExp, target, nil
Expand Down

0 comments on commit 4c72691

Please sign in to comment.