Skip to content

Commit

Permalink
autopilot: return error messages on run-once
Browse files Browse the repository at this point in the history
  • Loading branch information
m-schmoock committed Sep 8, 2021
1 parent a7b7c56 commit c4a1a70
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions autopilot/autopilot.py
Expand Up @@ -163,12 +163,14 @@ def run_once(plugin, dryrun=False):
# to open

if available_funds < plugin.min_capacity_sat:
plugin.log(f"Too low available funds: {available_funds} < {plugin.min_capacity_sat}")
return False
message = f"Too low available funds: {available_funds} < {plugin.min_capacity_sat}"
plugin.log(message)
return message

if len(channels) >= plugin.num_channels:
plugin.log(f"Already have {len(channels)} channels. Aim is for {plugin.num_channels}.")
return False
message = f"Already have {len(channels)} channels. Aim is for {plugin.num_channels}."
plugin.log(message)
return message

num_channels = min(
int(available_funds / plugin.min_capacity_sat),
Expand All @@ -182,7 +184,9 @@ def run_once(plugin, dryrun=False):

plugin.initialized.wait()
if plugin.initerror:
return f"Error: autopilot had initialization errors: {str(plugin.initerror)}"
message = f"Error: autopilot had initialization errors: {str(plugin.initerror)}"
plugin.log(message, 'error')
return message

candidates = plugin.autopilot.find_candidates(
num_channels,
Expand Down

0 comments on commit c4a1a70

Please sign in to comment.