mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-04 14:54:26 +01:00
pyln-client/gossmap: init GossmapNode and Id also with hexstring
also improves test coverage Changelog-Added: pyln-client: routines for direct access to the gossip store as Gossmap
This commit is contained in:
committed by
Rusty Russell
parent
fa8e74a2ad
commit
125752118a
@@ -55,6 +55,8 @@ class GossmapHalfchannel(object):
|
||||
|
||||
class GossmapNodeId(object):
|
||||
def __init__(self, buf: bytes):
|
||||
if isinstance(buf, str):
|
||||
buf = bytes.fromhex(buf)
|
||||
if len(buf) != 33 or (buf[0] != 2 and buf[0] != 3):
|
||||
raise ValueError("{} is not a valid node_id".format(buf.hex()))
|
||||
self.nodeid = buf
|
||||
@@ -139,6 +141,8 @@ class GossmapNode(object):
|
||||
.channels is a list of the GossmapChannels attached to this node.
|
||||
"""
|
||||
def __init__(self, node_id: GossmapNodeId):
|
||||
if isinstance(node_id, bytes) or isinstance(node_id, str):
|
||||
node_id = GossmapNodeId(node_id)
|
||||
self.announce_fields: Optional[Dict[str, Any]] = None
|
||||
self.announce_offset: Optional[int] = None
|
||||
self.channels: List[GossmapChannel] = []
|
||||
|
||||
Reference in New Issue
Block a user