From 4668f5668422671cb4195ae71cd92d354fb3113f Mon Sep 17 00:00:00 2001 From: PJ Date: Wed, 21 Aug 2024 11:27:52 +0200 Subject: [PATCH] worker: schedule sync on max bal exceeded --- worker/host.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/worker/host.go b/worker/host.go index 471a5b863..9c65bd0c2 100644 --- a/worker/host.go +++ b/worker/host.go @@ -2,6 +2,7 @@ package worker import ( "context" + "errors" "fmt" "io" "time" @@ -244,6 +245,9 @@ func (h *host) FundAccount(ctx context.Context, desired types.Currency, rev *typ // fund the account if err := h.client.FundAccount(ctx, rev, h.hk, h.siamuxAddr, deposit, h.acc.id, pt.HostPriceTable, h.renterKey); err != nil { + if rhp3.IsBalanceMaxExceeded(err) { + err = errors.Join(err, h.acc.as.ScheduleSync(ctx, h.acc.id, h.hk)) + } return types.ZeroCurrency, fmt.Errorf("failed to fund account with %v; %w", deposit, err) }