mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 20:09:18 +01:00
pyln-client/gossmap: make node and node_id comparable with __lt__ and __eq__
This commit is contained in:
parent
47efea92c6
commit
fa8e74a2ad
1 changed files with 15 additions and 1 deletions
|
@ -65,8 +65,12 @@ class GossmapNodeId(object):
|
|||
def __eq__(self, other):
|
||||
if not isinstance(other, GossmapNodeId):
|
||||
return False
|
||||
return self.nodeid.__eq__(other.nodeid)
|
||||
|
||||
return self.nodeid == other.nodeid
|
||||
def __lt__(self, other):
|
||||
if not isinstance(other, GossmapNodeId):
|
||||
raise ValueError(f"Cannot compare GossmapNodeId with {type(other)}")
|
||||
return self.nodeid.__lt__(other.nodeid) # yes, that works
|
||||
|
||||
def __hash__(self):
|
||||
return self.nodeid.__hash__()
|
||||
|
@ -143,6 +147,16 @@ class GossmapNode(object):
|
|||
def __repr__(self):
|
||||
return "GossmapNode[{}]".format(self.node_id.nodeid.hex())
|
||||
|
||||
def __eq__(self, other):
|
||||
if not isinstance(other, GossmapNode):
|
||||
return False
|
||||
return self.node_id.__eq__(other.node_id)
|
||||
|
||||
def __lt__(self, other):
|
||||
if not isinstance(other, GossmapNode):
|
||||
raise ValueError(f"Cannot compare GossmapNode with {type(other)}")
|
||||
return self.node_id.__lt__(other.node_id)
|
||||
|
||||
|
||||
class Gossmap(object):
|
||||
"""Class to represent the gossip map of the network"""
|
||||
|
|
Loading…
Add table
Reference in a new issue