@@ -33,17 +33,22 @@ def __init__(self, buf: bytes):
3333
3434class GossmapHalfchannel (object ):
3535 """One direction of a GossmapChannel."""
36- def __init__ (self , timestamp : int ,
37- cltv_expiry_delta : int ,
36+ def __init__ (self , channel : GossmapChannel , direction : int ,
37+ timestamp : int , cltv_expiry_delta : int ,
3838 htlc_minimum_msat : int , htlc_maximum_msat : int ,
3939 fee_base_msat : int , fee_proportional_millionths : int ):
40+ self .channel = channel
41+ self .direction = direction
4042 self .timestamp : int = timestamp
4143 self .cltv_expiry_delta : int = cltv_expiry_delta
4244 self .htlc_minimum_msat : int = htlc_minimum_msat
4345 self .htlc_maximum_msat : Optional [int ] = htlc_maximum_msat
4446 self .fee_base_msat : int = fee_base_msat
4547 self .fee_proportional_millionths : int = fee_proportional_millionths
4648
49+ def __repr__ (self ):
50+ return "GossmapHalfchannel[{}x{}]" .format (str (self .channel .scid ), self .direction )
51+
4752
4853class GossmapChannel (object ):
4954 """A channel: fields of channel_announcement are in .fields, optional updates are in .updates_fields, which can be None if there has been no channel update."""
@@ -72,7 +77,8 @@ def update_channel(self,
7277 self .updates_fields [direction ] = fields
7378 self .updates_offset = off
7479
75- half = GossmapHalfchannel (fields ['timestamp' ],
80+ half = GossmapHalfchannel (self , direction ,
81+ fields ['timestamp' ],
7682 fields ['cltv_expiry_delta' ],
7783 fields ['htlc_minimum_msat' ],
7884 fields .get ('htlc_maximum_msat' , None ),
@@ -86,6 +92,9 @@ def get_half_channel(self, direction: int):
8692 raise ValueError ("direction can only be 0 or 1" )
8793 return self .half_channels [direction ]
8894
95+ def __repr__ (self ):
96+ return "GossmapChannel[{}]" .format (str (self .scid ))
97+
8998
9099class GossmapNodeId (object ):
91100 def __init__ (self , buf : bytes ):
@@ -106,7 +115,7 @@ def __hash__(self):
106115 return self .nodeid .__hash__ ()
107116
108117 def __repr__ (self ):
109- return "GossmapNodeId[0x {}]" .format (self .nodeid .hex ())
118+ return "GossmapNodeId[{}]" .format (self .nodeid .hex ())
110119
111120 def from_str (self , s : str ):
112121 if s .startswith ('0x' ):
@@ -127,6 +136,9 @@ def __init__(self, node_id: GossmapNodeId):
127136 self .channels = []
128137 self .node_id = node_id
129138
139+ def __repr__ (self ):
140+ return "GossmapNode[{}]" .format (self .node_id .nodeid .hex ())
141+
130142
131143class Gossmap (object ):
132144 """Class to represent the gossip map of the network"""
0 commit comments