cleanups: feeadjuster, drain and summary

This commit is contained in:
Michael Schmoock
2022-02-16 11:32:21 +01:00
parent 6df68dcebc
commit 69e02e23b1
4 changed files with 12 additions and 14 deletions

View File

@@ -293,7 +293,7 @@ def try_for_htlc_fee(plugin, payload, peer_id, amount, chunk, spendable_before):
return False # should not happen, but maybe API changes
payload['success_msg'].append(f"{amount + fees}msat sent over {len(route)} "
f"hops to {payload['command']} {amount}msat "
f"[{chunk + 1}/{payload['chunks']}")
f"[{chunk + 1}/{payload['chunks']}]")
# we need to wait for HTLC to resolve, so remaining amounts
# can be calculated correctly for the next chunk
wait_ours(plugin, payload['scid'], ours)

View File

@@ -66,8 +66,7 @@ def get_ratio_hard(our_percentage):
def get_peer_id_for_scid(plugin: Plugin, scid: str):
for peer in plugin.peers:
for ch in peer['channels']:
if 'short_channel_id' in ch:
if ch['short_channel_id'] == scid:
if ch.get('short_channel_id') == scid:
return peer['id']
return None
@@ -75,8 +74,7 @@ def get_peer_id_for_scid(plugin: Plugin, scid: str):
def get_local_channel_for_scid(plugin: Plugin, scid: str):
for peer in plugin.peers:
for ch in peer['channels']:
if 'short_channel_id' in ch:
if ch['short_channel_id'] == scid:
if ch.get('short_channel_id') == scid:
return ch
return None
@@ -236,8 +234,8 @@ def feeadjust(plugin: Plugin, scid: str = None):
for peer in plugin.peers:
for chan in peer["channels"]:
if chan["state"] == "CHANNELD_NORMAL":
_scid = chan["short_channel_id"]
if scid != None and scid != _scid:
_scid = chan.get("short_channel_id")
if scid is not None and scid != _scid:
continue
plugin.adj_balances[_scid] = {
"our": int(chan["to_us_msat"]),

View File

@@ -24,7 +24,7 @@ try:
except Exception:
pass
Channel = namedtuple('Channel', ['total', 'ours', 'theirs', 'pid', 'private', 'connected', 'scid', 'avail', 'base' ,'permil'])
Channel = namedtuple('Channel', ['total', 'ours', 'theirs', 'pid', 'private', 'connected', 'scid', 'avail', 'base', 'permil'])
Charset = namedtuple('Charset', ['double_left', 'left', 'bar', 'mid', 'right', 'double_right', 'empty'])
if have_utf8:
draw = Charset('', '', '', '', '', '', '')
@@ -265,7 +265,7 @@ def init_db(plugin, retry_time=4, sleep_time=1):
retry += 1
if db is None:
raise Error("db initialization error")
raise RuntimeError("db initialization error")
return db