@@ -31,20 +31,6 @@ def __init__(self, buf: bytes):
31
31
self .length = (length & GOSSIP_STORE_LEN_MASK )
32
32
33
33
34
- class GossmapHalfchannel (object ):
35
- """One direction of a GossmapChannel."""
36
- def __init__ (self , timestamp : int ,
37
- cltv_expiry_delta : int ,
38
- htlc_minimum_msat : int , htlc_maximum_msat : int ,
39
- fee_base_msat : int , fee_proportional_millionths : int ):
40
- self .timestamp : int = timestamp
41
- self .cltv_expiry_delta : int = cltv_expiry_delta
42
- self .htlc_minimum_msat : int = htlc_minimum_msat
43
- self .htlc_maximum_msat : Optional [int ] = htlc_maximum_msat
44
- self .fee_base_msat : int = fee_base_msat
45
- self .fee_proportional_millionths : int = fee_proportional_millionths
46
-
47
-
48
34
class GossmapChannel (object ):
49
35
"""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."""
50
36
def __init__ (self ,
@@ -72,7 +58,8 @@ def update_channel(self,
72
58
self .updates_fields [direction ] = fields
73
59
self .updates_offset = off
74
60
75
- half = GossmapHalfchannel (fields ['timestamp' ],
61
+ half = GossmapHalfchannel (self , direction ,
62
+ fields ['timestamp' ],
76
63
fields ['cltv_expiry_delta' ],
77
64
fields ['htlc_minimum_msat' ],
78
65
fields .get ('htlc_maximum_msat' , None ),
@@ -86,6 +73,28 @@ def get_half_channel(self, direction: int):
86
73
raise ValueError ("direction can only be 0 or 1" )
87
74
return self .half_channels [direction ]
88
75
76
+ def __repr__ (self ):
77
+ return "GossmapChannel[{}]" .format (str (self .scid ))
78
+
79
+
80
+ class GossmapHalfchannel (object ):
81
+ """One direction of a GossmapChannel."""
82
+ def __init__ (self , channel : GossmapChannel , direction : int ,
83
+ timestamp : int , cltv_expiry_delta : int ,
84
+ htlc_minimum_msat : int , htlc_maximum_msat : int ,
85
+ fee_base_msat : int , fee_proportional_millionths : int ):
86
+ self .channel = channel
87
+ self .direction = direction
88
+ self .timestamp : int = timestamp
89
+ self .cltv_expiry_delta : int = cltv_expiry_delta
90
+ self .htlc_minimum_msat : int = htlc_minimum_msat
91
+ self .htlc_maximum_msat : Optional [int ] = htlc_maximum_msat
92
+ self .fee_base_msat : int = fee_base_msat
93
+ self .fee_proportional_millionths : int = fee_proportional_millionths
94
+
95
+ def __repr__ (self ):
96
+ return "GossmapHalfChannel[{}x{}]" .format (str (self .channel .scid ), self .direction )
97
+
89
98
90
99
class GossmapNodeId (object ):
91
100
def __init__ (self , buf : bytes ):
@@ -106,7 +115,7 @@ def __hash__(self):
106
115
return self .nodeid .__hash__ ()
107
116
108
117
def __repr__ (self ):
109
- return "GossmapNodeId[0x {}]" .format (self .nodeid .hex ())
118
+ return "GossmapNodeId[{}]" .format (self .nodeid .hex ())
110
119
111
120
def from_str (self , s : str ):
112
121
if s .startswith ('0x' ):
@@ -127,6 +136,9 @@ def __init__(self, node_id: GossmapNodeId):
127
136
self .channels = []
128
137
self .node_id = node_id
129
138
139
+ def __repr__ (self ):
140
+ return "GossmapNode[{}]" .format (self .node_id .nodeid .hex ())
141
+
130
142
131
143
class Gossmap (object ):
132
144
"""Class to represent the gossip map of the network"""
0 commit comments