Skip to content

Commit

Permalink
Check default case
Browse files Browse the repository at this point in the history
  • Loading branch information
scissorstail authored and accumulator committed Nov 22, 2022
1 parent 83caf18 commit d9dc8c9
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions charge_lnd/policy.py
Original file line number Diff line number Diff line change
Expand Up @@ -366,20 +366,18 @@ def match_by_chan(self, channel, config):
return False

htlcs_total = fwds['htlc_in'] + fwds['htlc_out']
if htlcs_total > 0:
htlcs_ratio = fwds['htlc_in'] / htlcs_total
if 'chan.max_htlcs_ratio' in config and not config.getfloat('chan.max_htlcs_ratio') >= htlcs_ratio:
return False
if 'chan.min_htlcs_ratio' in config and not config.getfloat('chan.min_htlcs_ratio') <= htlcs_ratio:
return False
htlcs_ratio = fwds['htlc_in'] / htlcs_total if htlcs_total else float('nan')
if 'chan.max_htlcs_ratio' in config and not config.getfloat('chan.max_htlcs_ratio') >= htlcs_ratio:
return False
if 'chan.min_htlcs_ratio' in config and not config.getfloat('chan.min_htlcs_ratio') <= htlcs_ratio:
return False

sats_total = fwds['sat_in'] + fwds['sat_out']
if sats_total > 0:
sats_ratio = fwds['sat_in'] / sats_total
if 'chan.max_sats_ratio' in config and not config.getfloat('chan.max_sats_ratio') >= sats_ratio:
return False
if 'chan.min_sats_ratio' in config and not config.getfloat('chan.min_sats_ratio') <= sats_ratio:
return False
sats_ratio = fwds['sat_in'] / sats_total if sats_total else float('nan')
if 'chan.max_sats_ratio' in config and not config.getfloat('chan.max_sats_ratio') >= sats_ratio:
return False
if 'chan.min_sats_ratio' in config and not config.getfloat('chan.min_sats_ratio') <= sats_ratio:
return False

return True

Expand Down

0 comments on commit d9dc8c9

Please sign in to comment.