mirror of
https://github.com/prusnak/suez.git
synced 2026-08-13 12:33:13 +02:00
filter public/private in suez.py not in clients
This commit is contained in:
parent
b85e72bbeb
commit
cd23289d4c
3 changed files with 11 additions and 31 deletions
14
clnclient.py
14
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"
|
||||
|
|
|
|||
14
lndclient.py
14
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"]
|
||||
|
|
|
|||
14
suez.py
14
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,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue