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.
This commit is contained in:
Johan T. Halseth 2018-12-19 14:54:53 +01:00
parent d0c4e253c6
commit d5f3714f86
No known key found for this signature in database
GPG Key ID: 15BAADA29DA20D26

@ -484,7 +484,15 @@ func (a *Agent) controller() {
availableFunds, numChans := a.cfg.Constraints.ChannelBudget( availableFunds, numChans := a.cfg.Constraints.ChannelBudget(
totalChans, a.totalBalance, 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 continue
} }