add LN gossip sync progress estimate indicator to Qt GUI
This commit is contained in:
@@ -198,7 +198,7 @@ class LNWorker(Logger):
|
||||
def peer_closed(self, peer: Peer) -> None:
|
||||
self.peers.pop(peer.pubkey)
|
||||
|
||||
def num_peers(self):
|
||||
def num_peers(self) -> int:
|
||||
return sum([p.is_initialized() for p in self.peers.values()])
|
||||
|
||||
def start_network(self, network: 'Network'):
|
||||
@@ -359,14 +359,27 @@ class LNGossip(LNWorker):
|
||||
self.unknown_ids.update(new)
|
||||
self.network.trigger_callback('unknown_channels', len(self.unknown_ids))
|
||||
self.network.trigger_callback('gossip_peers', self.num_peers())
|
||||
self.network.trigger_callback('ln_gossip_sync_progress')
|
||||
|
||||
def get_ids_to_query(self):
|
||||
N = 500
|
||||
l = list(self.unknown_ids)
|
||||
self.unknown_ids = set(l[N:])
|
||||
self.network.trigger_callback('unknown_channels', len(self.unknown_ids))
|
||||
self.network.trigger_callback('ln_gossip_sync_progress')
|
||||
return l[0:N]
|
||||
|
||||
def get_sync_progress_estimate(self) -> Tuple[Optional[int], Optional[int]]:
|
||||
if self.num_peers() == 0:
|
||||
return None, None
|
||||
num_db_channels = self.channel_db.num_channels
|
||||
nchans_with_0p, nchans_with_1p, nchans_with_2p = self.channel_db.get_num_channels_partitioned_by_policy_count()
|
||||
# some channels will never have two policies (only one is in gossip?...)
|
||||
# so if we have at least 1 policy for a channel, we consider that channel "complete" here
|
||||
current_est = num_db_channels - nchans_with_0p
|
||||
total_est = len(self.unknown_ids) + num_db_channels
|
||||
return current_est, total_est
|
||||
|
||||
|
||||
class LNWallet(LNWorker):
|
||||
|
||||
|
||||
Reference in New Issue
Block a user