2
2
3
3
from pyln .spec .bolt7 import (channel_announcement , channel_update ,
4
4
node_announcement )
5
+ from pyln .proto import ShortChannelId
5
6
from typing import Any , Dict , List , Optional
6
7
7
8
import io
@@ -28,11 +29,6 @@ def __init__(self, buf: bytes):
28
29
self .length = (length & GOSSIP_STORE_LEN_MASK )
29
30
30
31
31
- # FIXME!
32
- class short_channel_id (int ):
33
- pass
34
-
35
-
36
32
class point (bytes ):
37
33
pass
38
34
@@ -75,7 +71,7 @@ def __init__(self, store_filename: str = "gossip_store"):
75
71
self .store_file = open (store_filename , "rb" )
76
72
self .store_buf = bytes ()
77
73
self .nodes : Dict [point , GossmapNode ] = {}
78
- self .channels : Dict [short_channel_id , GossmapChannel ] = {}
74
+ self .channels : Dict [ShortChannelId , GossmapChannel ] = {}
79
75
version = self .store_file .read (1 )
80
76
if version [0 ] != GOSSIP_STORE_VERSION :
81
77
raise ValueError ("Invalid gossip store version {}" .format (version ))
@@ -85,7 +81,7 @@ def __init__(self, store_filename: str = "gossip_store"):
85
81
def _new_channel (self ,
86
82
fields : Dict [str , Any ],
87
83
announce_offset : int ,
88
- scid : short_channel_id ,
84
+ scid : ShortChannelId ,
89
85
node1_id : point ,
90
86
node2_id : point ,
91
87
is_private : bool ):
@@ -101,7 +97,7 @@ def _new_channel(self,
101
97
self .nodes [node1_id ].channels .append (c )
102
98
self .nodes [node2_id ].channels .append (c )
103
99
104
- def _del_channel (self , scid : short_channel_id ):
100
+ def _del_channel (self , scid : ShortChannelId ):
105
101
c = self .channels [scid ]
106
102
n1 = self .nodes [c .node1_id ]
107
103
n2 = self .nodes [c .node2_id ]
@@ -115,14 +111,15 @@ def _del_channel(self, scid: short_channel_id):
115
111
116
112
def add_channel (self , rec : bytes , off : int , is_private : bool ):
117
113
fields = channel_announcement .read (io .BytesIO (rec [2 :]), {})
118
- self ._new_channel (fields , off , fields ['short_channel_id' ],
114
+ self ._new_channel (fields , off ,
115
+ ShortChannelId .from_int (fields ['short_channel_id' ]),
119
116
fields ['node_id_1' ], fields ['node_id_2' ],
120
117
is_private )
121
118
122
119
def update_channel (self , rec : bytes , off : int ):
123
120
fields = channel_update .read (io .BytesIO (rec [2 :]), {})
124
121
direction = fields ['message_flags' ] & 1
125
- c = self .channels [fields ['short_channel_id' ]]
122
+ c = self .channels [ShortChannelId . from_int ( fields ['short_channel_id' ]) ]
126
123
c .updates_fields [direction ] = fields
127
124
c .updates_offset = off
128
125
0 commit comments