diff --git a/autopilot/contractor/contractor.go b/autopilot/contractor/contractor.go index c08a27d56..dbf087e70 100644 --- a/autopilot/contractor/contractor.go +++ b/autopilot/contractor/contractor.go @@ -696,8 +696,9 @@ LOOP: // if we were not able to the contract's revision, we can't properly // perform the checks that follow, however we do want to be lenient if // this contract is in the current set and we still have leeway left + _, inSet := inCurrentSet[fcid] if contract.Revision == nil { - if _, found := inCurrentSet[fcid]; !found || remainingKeepLeeway == 0 { + if !inSet || remainingKeepLeeway == 0 { toStopUsing[fcid] = errContractNoRevision.Error() } else if !ctx.AllowRedundantIPs() && ipFilter.IsRedundantIP(contract.HostIP, contract.HostKey) { toStopUsing[fcid] = fmt.Sprintf("%v; %v", api.ErrUsabilityHostRedundantIP, errContractNoRevision) @@ -711,7 +712,7 @@ LOOP: // decide whether the contract is still good ci := contractInfo{contract: contract, priceTable: host.PriceTable.HostPriceTable, settings: host.Settings} - usable, recoverable, refresh, renew, reasons := c.isUsableContract(ctx.AutopilotConfig(), ctx.state.RS, ci, bh, ipFilter) + usable, recoverable, refresh, renew, reasons := c.isUsableContract(ctx.AutopilotConfig(), ctx.state.RS, ci, inSet, bh, ipFilter) ci.usable = usable ci.recoverable = recoverable if !usable { diff --git a/autopilot/contractor/hostfilter.go b/autopilot/contractor/hostfilter.go index eb1a559a4..42ee045b3 100644 --- a/autopilot/contractor/hostfilter.go +++ b/autopilot/contractor/hostfilter.go @@ -102,7 +102,7 @@ func (u *unusableHostsBreakdown) keysAndValues() []interface{} { // - recoverable -> can be usable in the contract set if it is refreshed/renewed // - refresh -> should be refreshed // - renew -> should be renewed -func (c *Contractor) isUsableContract(cfg api.AutopilotConfig, rs api.RedundancySettings, ci contractInfo, bh uint64, f *ipFilter) (usable, recoverable, refresh, renew bool, reasons []string) { +func (c *Contractor) isUsableContract(cfg api.AutopilotConfig, rs api.RedundancySettings, ci contractInfo, inSet bool, bh uint64, f *ipFilter) (usable, recoverable, refresh, renew bool, reasons []string) { contract, s, pt := ci.contract, ci.settings, ci.priceTable usable = true @@ -121,14 +121,14 @@ func (c *Contractor) isUsableContract(cfg api.AutopilotConfig, rs api.Redundancy } else { if isOutOfCollateral(cfg, rs, contract, s, pt) { reasons = append(reasons, errContractOutOfCollateral.Error()) - usable = false - recoverable = true + usable = usable && inSet && c.shouldForgiveFailedRefresh(contract.ID) + recoverable = !usable // only needs to be recoverable if !usable refresh = true renew = false } if isOutOfFunds(cfg, pt, contract) { reasons = append(reasons, errContractOutOfFunds.Error()) - usable = usable && c.shouldForgiveFailedRefresh(contract.ID) + usable = usable && inSet && c.shouldForgiveFailedRefresh(contract.ID) recoverable = !usable // only needs to be recoverable if !usable refresh = true renew = false