From cd23289d4cd2ef4154f29f5f83e003d29a7dadc2 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Sun, 26 Feb 2023 13:17:44 +0100 Subject: [PATCH] filter public/private in suez.py not in clients --- clnclient.py | 14 +------------- lndclient.py | 14 +------------- suez.py | 14 +++++++++----- 3 files changed, 11 insertions(+), 31 deletions(-) diff --git a/clnclient.py b/clnclient.py index f025b44..d3f0547 100644 --- a/clnclient.py +++ b/clnclient.py @@ -5,20 +5,10 @@ from channel import Channel class ClnClient: - def __init__(self, client_args, include_private, include_public): + def __init__(self, client_args): self.client_args = client_args - self.include_private = include_private - self.include_public = include_public self.refresh() - def should_exclude(self, c): - return ( - c["private"] - and not self.include_private - or not c["private"] - and not self.include_public - ) - def refresh(self): gi = self._run("getinfo") self.local_pubkey = gi["id"] @@ -31,8 +21,6 @@ class ClnClient: for p in peers: if p["channels"]: for c in p["channels"]: - if self.should_exclude(c): - continue chan = Channel() chan.chan_id = c.get("short_channel_id") chan.active = c["state"] == "CHANNELD_NORMAL" diff --git a/lndclient.py b/lndclient.py index 9244da6..62c4f9e 100644 --- a/lndclient.py +++ b/lndclient.py @@ -5,10 +5,8 @@ from channel import Channel class LndClient(abc.ABC): - def __init__(self, client_args, include_private, include_public): + def __init__(self, client_args): self.client_args = client_args - self.include_private = include_private - self.include_public = include_public self.refresh() @abc.abstractmethod @@ -35,14 +33,6 @@ class LndClient(abc.ABC): def updatechanpolicy(self, channel_point, policy): pass - def should_exclude(self, c): - return ( - c["private"] - and not self.include_private - or not c["private"] - and not self.include_public - ) - def refresh(self): gi = self.getinfo() self.local_pubkey = gi["identity_pubkey"] @@ -51,8 +41,6 @@ class LndClient(abc.ABC): channels = self.listchannels()["channels"] for c in channels: - if self.should_exclude(c): - continue chan = Channel() chan.chan_id = c["chan_id"] chan.active = c["active"] diff --git a/suez.py b/suez.py index 7f4bad6..ea7fd2d 100644 --- a/suez.py +++ b/suez.py @@ -233,10 +233,7 @@ def suez( "lnd-rest": LndRestClient, } - include_private = channels in ["all", "private", "split"] - include_public = channels in ["all", "public", "split"] - - ln = clients[client](client_args, include_private, include_public) + ln = clients[client](client_args) score = Score() if show_scores else None @@ -282,8 +279,15 @@ def suez( console.print(private_info) console.print() else: + if channels == "public": + show_channels = [c for c in ln.channels.values() if not c.private] + elif channels == "private": + show_channels = [c for c in ln.channels.values() if c.private] + else: # all + show_channels = ln.channels.values() + table = channel_table( - ln.channels.values(), + show_channels, score, show_remote_fees, show_chan_ids,