feeadjuster: review fixes part 2

This commit is contained in:
Gálli Zoltán
2020-12-08 20:30:55 +01:00
committed by Christian Decker
parent fabb7d370a
commit 0a3fe31056
2 changed files with 9 additions and 6 deletions

View File

@@ -21,13 +21,15 @@ def get_adjusted_percentage(plugin: Plugin, scid: str):
"""
channel = plugin.adj_balances[scid]
min_liquidity = min(channel["total"] / 2, int(plugin.big_enough_liquidity))
theirs = channel["total"] - channel["our"]
if channel["our"] >= min_liquidity and theirs >= min_liquidity:
# the liquidity is just okay
return 0.5
if channel["our"] < min_liquidity:
percentage = channel["our"] / min_liquidity / 2
elif channel["total"] - channel["our"] < min_liquidity:
percentage = (min_liquidity + channel["our"] - channel["total"]) / min_liquidity / 2 + 0.5
else:
percentage = 0.5
return percentage
# our liquidity is too low
return channel["our"] / min_liquidity / 2
# their liquidity is too low
return (min_liquidity - theirs) / min_liquidity / 2 + 0.5
def get_ratio_soft(our_percentage):

View File

@@ -278,6 +278,7 @@ def test_feeadjuster_big_enough_liquidity(node_factory):
# Let's move another 0.003btc -> the channels will be at 0.006btc
amount = 300000000
pay(l1, l3, amount)
l2.wait_for_htlcs()
assert not l2.daemon.is_in_log("Adjusted fees", log_offset)
# Sending another 0.0033btc will result in a channel balance of 0.0093btc