2
2
3
3
from pyln .spec .bolt7 import (channel_announcement , channel_update ,
4
4
node_announcement )
5
- from typing import Dict , List , Optional
5
+ from typing import Any , Dict , List , Optional
6
6
7
7
import io
8
8
import struct
@@ -39,25 +39,25 @@ class point(bytes):
39
39
40
40
class GossmapChannel (object ):
41
41
def __init__ (self ,
42
- announce : bytes ,
42
+ fields : Dict [ str , Any ] ,
43
43
announce_offset : int ,
44
44
scid ,
45
45
node1_id : point ,
46
46
node2_id : point ,
47
47
is_private : bool ):
48
- self .announce = announce
48
+ self .fields = fields
49
49
self .announce_offset = announce_offset
50
50
self .is_private = is_private
51
51
self .scid = scid
52
52
self .node1_id = node1_id
53
53
self .node2_id = node2_id
54
- self .updates : List [Optional [bytes ]] = [None , None ]
54
+ self .updates_fields : List [Optional [Dict [ str , Any ] ]] = [None , None ]
55
55
self .updates_offset : List [Optional [int ]] = [None , None ]
56
56
57
57
58
58
class GossmapNode (object ):
59
59
def __init__ (self , node_id : point ):
60
- self .announce = None
60
+ self .announce_fields : Optional [ Dict [ str , Any ]] = None
61
61
self .announce_offset = None
62
62
self .channels = []
63
63
self .node_id = node_id
@@ -78,13 +78,13 @@ def __init__(self, store_filename: str = "gossip_store"):
78
78
self .refresh ()
79
79
80
80
def _new_channel (self ,
81
- announce : bytes ,
81
+ fields : Dict [ str , Any ] ,
82
82
announce_offset : int ,
83
83
scid : short_channel_id ,
84
84
node1_id : point ,
85
85
node2_id : point ,
86
86
is_private : bool ):
87
- c = GossmapChannel (announce , announce_offset ,
87
+ c = GossmapChannel (fields , announce_offset ,
88
88
scid , node1_id , node2_id ,
89
89
is_private )
90
90
if node1_id not in self .nodes :
@@ -110,20 +110,20 @@ def _del_channel(self, scid: short_channel_id):
110
110
111
111
def add_channel (self , rec : bytes , off : int , is_private : bool ):
112
112
fields = channel_announcement .read (io .BytesIO (rec [2 :]), {})
113
- self ._new_channel (rec , off , fields ['short_channel_id' ],
113
+ self ._new_channel (fields , off , fields ['short_channel_id' ],
114
114
fields ['node_id_1' ], fields ['node_id_2' ],
115
115
is_private )
116
116
117
117
def update_channel (self , rec : bytes , off : int ):
118
118
fields = channel_update .read (io .BytesIO (rec [2 :]), {})
119
119
direction = fields ['message_flags' ] & 1
120
120
c = self .channels [fields ['short_channel_id' ]]
121
- c .updates [direction ] = rec
121
+ c .updates_fields [direction ] = fields
122
122
c .updates_offset = off
123
123
124
124
def add_node_announcement (self , rec : bytes , off : int ):
125
125
fields = node_announcement .read (io .BytesIO (rec [2 :]), {})
126
- self .nodes [fields ['node_id' ]].announce = rec
126
+ self .nodes [fields ['node_id' ]].announce_fields = fields
127
127
self .nodes [fields ['node_id' ]].announce_offset = off
128
128
129
129
def reopen_store (self ):
0 commit comments