mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 22:45:27 +01:00
pygossmap: adds get_halfchannel
This commit is contained in:
parent
d50722d26b
commit
5a9a3d83c9
2 changed files with 12 additions and 1 deletions
|
@ -262,6 +262,17 @@ class Gossmap(object):
|
|||
short_channel_id = ShortChannelId.from_str(short_channel_id)
|
||||
return self.channels.get(short_channel_id)
|
||||
|
||||
def get_halfchannel(self,
|
||||
short_channel_id: Union[ShortChannelId, str],
|
||||
direction: int):
|
||||
""" Returns a GossmapHalfchannel identified by a scid and direction. """
|
||||
assert short_channel_id is not None
|
||||
if isinstance(short_channel_id, str):
|
||||
short_channel_id = ShortChannelId.from_str(short_channel_id)
|
||||
assert direction in [0, 1], "direction can only be 0 or 1"
|
||||
channel = self.get_channel(short_channel_id)
|
||||
return channel.half_channels[direction]
|
||||
|
||||
def get_node(self, node_id: Union[GossmapNodeId, str]):
|
||||
""" Resolves a node by its public key node_id """
|
||||
if isinstance(node_id, str):
|
||||
|
|
|
@ -70,7 +70,7 @@ def test_gossmap_halfchannel(tmp_path):
|
|||
assert chan.node2 == n2
|
||||
|
||||
half0 = chan.get_direction(0)
|
||||
half1 = chan.get_direction(1)
|
||||
half1 = g.get_halfchannel("103x1x1", 1)
|
||||
assert half0
|
||||
assert half1
|
||||
assert half0.direction == 0
|
||||
|
|
Loading…
Add table
Reference in a new issue