mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-30 08:51:32 +00:00
ChannelDB: print_graph
This commit is contained in:
parent
135951a13f
commit
21e907a4e3
2 changed files with 40 additions and 1 deletions
|
@ -825,8 +825,9 @@ class Peer(PrintError):
|
|||
short_chan_id = route[sender_idx + 1].short_channel_id
|
||||
except IndexError:
|
||||
print("payment destination reported error")
|
||||
else:
|
||||
self.network.path_finder.blacklist.add(short_chan_id)
|
||||
|
||||
self.network.path_finder.blacklist.add(short_chan_id)
|
||||
self.update_fail_htlc[payload["channel_id"]].put_nowait("HTLC failure with code {} (categories {})".format(code, codes))
|
||||
|
||||
@aiosafe
|
||||
|
|
|
@ -140,6 +140,44 @@ class ChannelDB(PrintError):
|
|||
except KeyError:
|
||||
pass
|
||||
|
||||
def print_graph(self, full_ids=False):
|
||||
# used for debugging.
|
||||
# FIXME there is a race here - iterables could change size from another thread
|
||||
def other_node_id(node_id, channel_id):
|
||||
channel_info = self._id_to_channel_info[channel_id]
|
||||
if node_id == channel_info.node_id_1:
|
||||
other = channel_info.node_id_2
|
||||
else:
|
||||
other = channel_info.node_id_1
|
||||
return other if full_ids else other[-4:]
|
||||
|
||||
self.print_msg('node: {(channel, other_node), ...}')
|
||||
for node_id, short_channel_ids in list(self._channels_for_node.items()):
|
||||
short_channel_ids = {(bh2u(cid), bh2u(other_node_id(node_id, cid)))
|
||||
for cid in short_channel_ids}
|
||||
node_id = bh2u(node_id) if full_ids else bh2u(node_id[-4:])
|
||||
self.print_msg('{}: {}'.format(node_id, short_channel_ids))
|
||||
|
||||
self.print_msg('channel: node1, node2, direction')
|
||||
for short_channel_id, channel_info in list(self._id_to_channel_info.items()):
|
||||
node1 = channel_info.node_id_1
|
||||
node2 = channel_info.node_id_2
|
||||
direction1 = channel_info.get_policy_for_node(node1) is not None
|
||||
direction2 = channel_info.get_policy_for_node(node2) is not None
|
||||
if direction1 and direction2:
|
||||
direction = 'both'
|
||||
elif direction1:
|
||||
direction = 'forward'
|
||||
elif direction2:
|
||||
direction = 'backward'
|
||||
else:
|
||||
direction = 'none'
|
||||
self.print_msg('{}: {}, {}, {}'
|
||||
.format(bh2u(short_channel_id),
|
||||
bh2u(node1) if full_ids else bh2u(node1[-4:]),
|
||||
bh2u(node2) if full_ids else bh2u(node2[-4:]),
|
||||
direction))
|
||||
|
||||
|
||||
class RouteEdge:
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue