From d5f3714f862c0f827d67f7631aedd113cd5d5392 Mon Sep 17 00:00:00 2001 From: "Johan T. Halseth" Date: Wed, 19 Dec 2018 14:54:53 +0100 Subject: [PATCH] autopilot/agent: return early if no funds available If there are less funds available than the minumum channel size, there's no reason to score candidates, so we continue early. --- autopilot/agent.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/autopilot/agent.go b/autopilot/agent.go index bc900994..86ce85e1 100644 --- a/autopilot/agent.go +++ b/autopilot/agent.go @@ -484,7 +484,15 @@ func (a *Agent) controller() { availableFunds, numChans := a.cfg.Constraints.ChannelBudget( totalChans, a.totalBalance, ) - if numChans == 0 { + switch { + case numChans == 0: + continue + + // If the amount is too small, we don't want to attempt opening + // another channel. + case availableFunds == 0: + continue + case availableFunds < a.cfg.Constraints.MinChanSize(): continue }