Merge pull request #9603 from spesmilo/gossip_info
gossip: less log lines, use command line instead
This commit is contained in:
@@ -493,7 +493,6 @@ class ChannelDB(SqlDB):
|
|||||||
added += self.ca_verifier.add_new_channel_info(short_channel_id, msg)
|
added += self.ca_verifier.add_new_channel_info(short_channel_id, msg)
|
||||||
|
|
||||||
self.update_counts()
|
self.update_counts()
|
||||||
self.logger.debug('add_channel_announcement: %d/%d'%(added, len(msg_payloads)))
|
|
||||||
|
|
||||||
def add_verified_channel_info(self, msg: dict, *, capacity_sat: int = None) -> None:
|
def add_verified_channel_info(self, msg: dict, *, capacity_sat: int = None) -> None:
|
||||||
try:
|
try:
|
||||||
@@ -724,7 +723,6 @@ class ChannelDB(SqlDB):
|
|||||||
if fwd_msg := GossipForwardingMessage.from_payload(msg_payload):
|
if fwd_msg := GossipForwardingMessage.from_payload(msg_payload):
|
||||||
self.fwd_node_announcements.append(fwd_msg)
|
self.fwd_node_announcements.append(fwd_msg)
|
||||||
|
|
||||||
self.logger.debug("on_node_announcement: %d/%d"%(len(new_nodes), len(msg_payloads)))
|
|
||||||
self.update_counts()
|
self.update_counts()
|
||||||
|
|
||||||
def get_old_policies(self, delta) -> Sequence[Tuple[bytes, ShortChannelID]]:
|
def get_old_policies(self, delta) -> Sequence[Tuple[bytes, ShortChannelID]]:
|
||||||
|
|||||||
@@ -1199,6 +1199,28 @@ class Commands(Logger):
|
|||||||
await lnworker.add_peer(connection_string)
|
await lnworker.add_peer(connection_string)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@command('wnl')
|
||||||
|
async def gossip_info(self, wallet: Abstract_Wallet = None):
|
||||||
|
"""Display statistics about lightninig gossip"""
|
||||||
|
lngossip = self.network.lngossip
|
||||||
|
channel_db = lngossip.channel_db
|
||||||
|
forwarded = dict([(key.hex(), p._num_gossip_messages_forwarded) for key, p in wallet.lnworker.peers.items()]),
|
||||||
|
out = {
|
||||||
|
'received': {
|
||||||
|
'channel_announcements': lngossip._num_chan_ann,
|
||||||
|
'channel_updates': lngossip._num_chan_upd,
|
||||||
|
'channel_updates_good': lngossip._num_chan_upd_good,
|
||||||
|
'node_announcements': lngossip._num_node_ann,
|
||||||
|
},
|
||||||
|
'database': {
|
||||||
|
'nodes': channel_db.num_nodes,
|
||||||
|
'channels': channel_db.num_channels,
|
||||||
|
'channel_policies': channel_db.num_policies,
|
||||||
|
},
|
||||||
|
'forwarded': forwarded,
|
||||||
|
}
|
||||||
|
return out
|
||||||
|
|
||||||
@command('wnl')
|
@command('wnl')
|
||||||
async def list_peers(self, gossip=False, wallet: Abstract_Wallet = None):
|
async def list_peers(self, gossip=False, wallet: Abstract_Wallet = None):
|
||||||
lnworker = self.network.lngossip if gossip else wallet.lnworker
|
lnworker = self.network.lngossip if gossip else wallet.lnworker
|
||||||
|
|||||||
@@ -130,6 +130,7 @@ class Peer(Logger, EventListener):
|
|||||||
self.received_commitsig_event = asyncio.Event()
|
self.received_commitsig_event = asyncio.Event()
|
||||||
self.downstream_htlc_resolved_event = asyncio.Event()
|
self.downstream_htlc_resolved_event = asyncio.Event()
|
||||||
self.register_callbacks()
|
self.register_callbacks()
|
||||||
|
self._num_gossip_messages_forwarded = 0
|
||||||
|
|
||||||
def send_message(self, message_name: str, **kwargs):
|
def send_message(self, message_name: str, **kwargs):
|
||||||
assert util.get_running_loop() == util.get_asyncio_loop(), f"this must be run on the asyncio thread!"
|
assert util.get_running_loop() == util.get_asyncio_loop(), f"this must be run on the asyncio thread!"
|
||||||
@@ -596,7 +597,8 @@ class Peer(Logger, EventListener):
|
|||||||
filter.only_forwarding = True
|
filter.only_forwarding = True
|
||||||
sent = await self._send_gossip_messages(requested_gossip)
|
sent = await self._send_gossip_messages(requested_gossip)
|
||||||
if sent > 0:
|
if sent > 0:
|
||||||
self.logger.debug(f"forwarded {sent} historical gossip messages to {self.pubkey.hex()}")
|
self._num_gossip_messages_forwarded += sent
|
||||||
|
#self.logger.debug(f"forwarded {sent} historical gossip messages to {self.pubkey.hex()}")
|
||||||
|
|
||||||
async def _send_gossip_messages(self, messages: List[GossipForwardingMessage]) -> int:
|
async def _send_gossip_messages(self, messages: List[GossipForwardingMessage]) -> int:
|
||||||
amount_sent = 0
|
amount_sent = 0
|
||||||
@@ -799,7 +801,7 @@ class Peer(Logger, EventListener):
|
|||||||
self.outgoing_gossip_reply = False
|
self.outgoing_gossip_reply = False
|
||||||
|
|
||||||
async def get_short_channel_ids(self, ids):
|
async def get_short_channel_ids(self, ids):
|
||||||
self.logger.info(f'Querying {len(ids)} short_channel_ids')
|
#self.logger.info(f'Querying {len(ids)} short_channel_ids')
|
||||||
assert not self.querying.is_set()
|
assert not self.querying.is_set()
|
||||||
self.query_short_channel_ids(ids)
|
self.query_short_channel_ids(ids)
|
||||||
await self.querying.wait()
|
await self.querying.wait()
|
||||||
|
|||||||
@@ -540,6 +540,11 @@ class LNGossip(LNWorker):
|
|||||||
self._last_gossip_batch_ts = 0 # type: int
|
self._last_gossip_batch_ts = 0 # type: int
|
||||||
self._forwarding_gossip_lock = asyncio.Lock()
|
self._forwarding_gossip_lock = asyncio.Lock()
|
||||||
self.gossip_request_semaphore = asyncio.Semaphore(5)
|
self.gossip_request_semaphore = asyncio.Semaphore(5)
|
||||||
|
# statistics
|
||||||
|
self._num_chan_ann = 0
|
||||||
|
self._num_node_ann = 0
|
||||||
|
self._num_chan_upd = 0
|
||||||
|
self._num_chan_upd_good = 0
|
||||||
|
|
||||||
def start_network(self, network: 'Network'):
|
def start_network(self, network: 'Network'):
|
||||||
super().start_network(network)
|
super().start_network(network)
|
||||||
@@ -623,8 +628,7 @@ class LNGossip(LNWorker):
|
|||||||
# note: we run in the originating peer's TaskGroup, so we can safely raise here
|
# note: we run in the originating peer's TaskGroup, so we can safely raise here
|
||||||
# and disconnect only from that peer
|
# and disconnect only from that peer
|
||||||
await self.channel_db.data_loaded.wait()
|
await self.channel_db.data_loaded.wait()
|
||||||
self.logger.debug(f'process_gossip ca: {len(chan_anns)} na: {len(node_anns)} '
|
|
||||||
f'cu: {len(chan_upds)}')
|
|
||||||
# channel announcements
|
# channel announcements
|
||||||
def process_chan_anns():
|
def process_chan_anns():
|
||||||
for payload in chan_anns:
|
for payload in chan_anns:
|
||||||
@@ -648,8 +652,11 @@ class LNGossip(LNWorker):
|
|||||||
self.logger.info(f'adding {len(orphaned)} unknown channel ids')
|
self.logger.info(f'adding {len(orphaned)} unknown channel ids')
|
||||||
orphaned_ids = [c['short_channel_id'] for c in orphaned]
|
orphaned_ids = [c['short_channel_id'] for c in orphaned]
|
||||||
await self.add_new_ids(orphaned_ids)
|
await self.add_new_ids(orphaned_ids)
|
||||||
if categorized_chan_upds.good:
|
|
||||||
self.logger.debug(f'process_gossip: {len(categorized_chan_upds.good)}/{len(chan_upds)}')
|
self._num_chan_ann += len(chan_anns)
|
||||||
|
self._num_node_ann += len(node_anns)
|
||||||
|
self._num_chan_upd += len(chan_upds)
|
||||||
|
self._num_chan_upd_good += len(categorized_chan_upds.good)
|
||||||
|
|
||||||
def is_synced(self) -> bool:
|
def is_synced(self) -> bool:
|
||||||
_, _, percentage_synced = self.get_sync_progress_estimate()
|
_, _, percentage_synced = self.get_sync_progress_estimate()
|
||||||
|
|||||||
Reference in New Issue
Block a user