electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit d30307b29e83ec2b0b08940c511d3681c8d2d0f5
parent eb4e6bb0de493877c0c7553928b4408787d79c92
Author: ThomasV <thomasv@electrum.org>
Date:   Sat, 18 May 2019 11:03:51 +0200

gui: improve display of lightning status

Diffstat:
Melectrum/gui/qt/lightning_dialog.py | 19+++++++++----------
Melectrum/lnworker.py | 9+++++----
2 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/electrum/gui/qt/lightning_dialog.py b/electrum/gui/qt/lightning_dialog.py @@ -80,6 +80,10 @@ class LightningDialog(QDialog): network_vbox = QVBoxLayout(network_w) self.num_peers = QLabel('') network_vbox.addWidget(self.num_peers) + self.num_nodes = QLabel('') + network_vbox.addWidget(self.num_nodes) + self.num_channels = QLabel('') + network_vbox.addWidget(self.num_channels) self.status = QLabel('') network_vbox.addWidget(self.status) network_vbox.addStretch(1) @@ -110,16 +114,11 @@ class LightningDialog(QDialog): self.watcher_list.update() self.network.register_callback(self.update_status, ['ln_status']) - def update_status(self, event): - if self.network.lngossip is None: - return - channel_db = self.network.channel_db - num_peers = sum([p.initialized.is_set() for p in self.network.lngossip.peers.values()]) - self.num_peers.setText(f'{num_peers} peers, {channel_db.num_nodes} nodes') - known = channel_db.num_channels - unknown = len(self.network.lngossip.unknown_ids) - msg = _(f'Channels: {known} of {known + unknown}') - self.status.setText(msg) + def update_status(self, event, num_peers, num_nodes, known, unknown): + self.num_peers.setText(_(f'Connected to {num_peers} peers')) + self.num_nodes.setText(_(f'{num_nodes} nodes')) + self.num_channels.setText(_(f'{known} channels')) + self.status.setText(_(f'Requesting {unknown} channels...') if unknown else '') def on_close(self): url = self.watchtower_e.text() diff --git a/electrum/lnworker.py b/electrum/lnworker.py @@ -98,7 +98,6 @@ class LNWorker(Logger): peer = Peer(self, node_id, transport) self.peers[node_id] = peer await self.network.main_taskgroup.spawn(peer.main_loop()) - self.network.trigger_callback('ln_status') await asyncio.start_server(cb, addr, int(port)) @log_exceptions @@ -125,7 +124,7 @@ class LNWorker(Logger): peer = Peer(self, node_id, transport) await self.network.main_taskgroup.spawn(peer.main_loop()) self.peers[node_id] = peer - self.network.trigger_callback('ln_status') + self.network.lngossip.refresh_gui() return peer def start_network(self, network: 'Network'): @@ -251,8 +250,10 @@ class LNGossip(LNWorker): # refresh gui known = self.channel_db.num_channels unknown = len(self.unknown_ids) - self.logger.info(f'Channels: {known} of {known+unknown}') - self.network.trigger_callback('ln_status') + num_nodes = self.channel_db.num_nodes + num_peers = sum([p.initialized.is_set() for p in self.peers.values()]) + self.logger.info(f'Channels: {known}. Missing: {unknown}') + self.network.trigger_callback('ln_status', num_peers, num_nodes, known, unknown) async def maintain_db(self): n = self.channel_db.get_orphaned_channels()