From 67cf2996f02e368a28734028bbaf91a38c17fb35 Mon Sep 17 00:00:00 2001 From: Chris Schinnerl Date: Mon, 29 Jul 2024 10:43:18 +0200 Subject: [PATCH] worker: address review comments --- worker/interactions.go | 14 -------------- worker/pricetables.go | 13 +++++++++++++ worker/worker.go | 11 ++++++++--- 3 files changed, 21 insertions(+), 17 deletions(-) delete mode 100644 worker/interactions.go diff --git a/worker/interactions.go b/worker/interactions.go deleted file mode 100644 index ac6b4f059..000000000 --- a/worker/interactions.go +++ /dev/null @@ -1,14 +0,0 @@ -package worker - -func shouldRecordPriceTable(err error) bool { - // List of errors that are considered 'successful' failures. Meaning that - // the host was reachable but we were unable to obtain a price table due to - // reasons out of the host's control. - if isInsufficientFunds(err) { - return false - } - if isBalanceInsufficient(err) { - return false - } - return true -} diff --git a/worker/pricetables.go b/worker/pricetables.go index a600c4cd1..6cc5f181a 100644 --- a/worker/pricetables.go +++ b/worker/pricetables.go @@ -193,3 +193,16 @@ func (p *priceTable) fetch(ctx context.Context, rev *types.FileContractRevision) } return } + +func shouldRecordPriceTable(err error) bool { + // List of errors that are considered 'successful' failures. Meaning that + // the host was reachable but we were unable to obtain a price table due to + // reasons out of the host's control. + if isInsufficientFunds(err) { + return false + } + if isBalanceInsufficient(err) { + return false + } + return true +} diff --git a/worker/worker.go b/worker/worker.go index c01ba8617..392cbd6c2 100644 --- a/worker/worker.go +++ b/worker/worker.go @@ -1489,9 +1489,14 @@ func (w *worker) scanHost(ctx context.Context, timeout time.Duration, hostKey ty HostKey: hostKey, PriceTable: pt, Subnets: subnets, - Success: err == nil, - Settings: settings, - Timestamp: time.Now(), + + // NOTE: A scan is considered successful if both fetching the price + // table and the settings succeeded. Right now scanning can't fail + // due to a reason that is our fault unless we are offline. If that + // changes, we should adjust this code to account for that. + Success: err == nil, + Settings: settings, + Timestamp: time.Now(), }, }) if scanErr != nil {