@@ -72,6 +72,7 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
72
72
73
73
let node_id_1_index: BigSize = Readable :: read ( read_cursor) ?;
74
74
let node_id_2_index: BigSize = Readable :: read ( read_cursor) ?;
75
+
75
76
if max ( node_id_1_index. 0 , node_id_2_index. 0 ) >= node_id_count as u64 {
76
77
return Err ( DecodeError :: InvalidValue . into ( ) ) ;
77
78
} ;
@@ -120,49 +121,43 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
120
121
// flags are always sent in full, and hence always need updating
121
122
let standard_channel_flags = channel_flags & 0b_0000_0011 ;
122
123
123
- let mut synthetic_update = if channel_flags & 0b_1000_0000 == 0 {
124
- // full update, field flags will indicate deviations from the default
125
- UnsignedChannelUpdate {
126
- chain_hash,
127
- short_channel_id,
128
- timestamp : backdated_timestamp,
129
- flags : standard_channel_flags,
130
- cltv_expiry_delta : default_cltv_expiry_delta,
131
- htlc_minimum_msat : default_htlc_minimum_msat,
132
- htlc_maximum_msat : default_htlc_maximum_msat,
133
- fee_base_msat : default_fee_base_msat,
134
- fee_proportional_millionths : default_fee_proportional_millionths,
135
- excess_data : Vec :: new ( ) ,
136
- }
137
- } else {
124
+ let mut synthetic_update = UnsignedChannelUpdate {
125
+ chain_hash,
126
+ short_channel_id,
127
+ timestamp : backdated_timestamp,
128
+ flags : standard_channel_flags,
129
+ cltv_expiry_delta : default_cltv_expiry_delta,
130
+ htlc_minimum_msat : default_htlc_minimum_msat,
131
+ htlc_maximum_msat : default_htlc_maximum_msat,
132
+ fee_base_msat : default_fee_base_msat,
133
+ fee_proportional_millionths : default_fee_proportional_millionths,
134
+ excess_data : Vec :: new ( ) ,
135
+ } ;
136
+
137
+ let mut skip_update_for_unknown_channel = false ;
138
+
139
+ if ( channel_flags & 0b_1000_0000 ) != 0 {
138
140
// incremental update, field flags will indicate mutated values
139
141
let read_only_network_graph = network_graph. read_only ( ) ;
140
- let channel = read_only_network_graph
142
+ if let Some ( channel) = read_only_network_graph
141
143
. channels ( )
142
- . get ( & short_channel_id)
143
- . ok_or ( LightningError {
144
- err : "Couldn't find channel for update" . to_owned ( ) ,
145
- action : ErrorAction :: IgnoreError ,
146
- } ) ?;
147
-
148
- let directional_info = channel
149
- . get_directional_info ( channel_flags)
150
- . ok_or ( LightningError {
151
- err : "Couldn't find previous directional data for update" . to_owned ( ) ,
152
- action : ErrorAction :: IgnoreError ,
153
- } ) ?;
154
-
155
- UnsignedChannelUpdate {
156
- chain_hash,
157
- short_channel_id,
158
- timestamp : backdated_timestamp,
159
- flags : standard_channel_flags,
160
- cltv_expiry_delta : directional_info. cltv_expiry_delta ,
161
- htlc_minimum_msat : directional_info. htlc_minimum_msat ,
162
- htlc_maximum_msat : directional_info. htlc_maximum_msat ,
163
- fee_base_msat : directional_info. fees . base_msat ,
164
- fee_proportional_millionths : directional_info. fees . proportional_millionths ,
165
- excess_data : Vec :: new ( ) ,
144
+ . get ( & short_channel_id) {
145
+
146
+ let directional_info = channel
147
+ . get_directional_info ( channel_flags)
148
+ . ok_or ( LightningError {
149
+ err : "Couldn't find previous directional data for update" . to_owned ( ) ,
150
+ action : ErrorAction :: IgnoreError ,
151
+ } ) ?;
152
+
153
+ synthetic_update. cltv_expiry_delta = directional_info. cltv_expiry_delta ;
154
+ synthetic_update. htlc_minimum_msat = directional_info. htlc_minimum_msat ;
155
+ synthetic_update. htlc_maximum_msat = directional_info. htlc_maximum_msat ;
156
+ synthetic_update. fee_base_msat = directional_info. fees . base_msat ;
157
+ synthetic_update. fee_proportional_millionths = directional_info. fees . proportional_millionths ;
158
+
159
+ } else {
160
+ skip_update_for_unknown_channel = true ;
166
161
}
167
162
} ;
168
163
@@ -191,6 +186,10 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
191
186
synthetic_update. htlc_maximum_msat = htlc_maximum_msat;
192
187
}
193
188
189
+ if skip_update_for_unknown_channel {
190
+ continue ;
191
+ }
192
+
194
193
match network_graph. update_channel_unsigned ( & synthetic_update) {
195
194
Ok ( _) => { } ,
196
195
Err ( LightningError { action : ErrorAction :: IgnoreDuplicateGossip , .. } ) => { } ,
@@ -251,7 +250,7 @@ mod tests {
251
250
}
252
251
253
252
#[ test]
254
- fn incremental_only_update_fails_without_prior_announcements ( ) {
253
+ fn incremental_only_update_ignores_missing_channel ( ) {
255
254
let incremental_update_input = vec ! [
256
255
76 , 68 , 75 , 1 , 111 , 226 , 140 , 10 , 182 , 241 , 179 , 114 , 193 , 166 , 162 , 70 , 174 , 99 , 247 ,
257
256
79 , 147 , 30 , 131 , 101 , 225 , 90 , 8 , 156 , 104 , 214 , 25 , 0 , 0 , 0 , 0 , 0 , 97 , 229 , 183 , 167 ,
@@ -268,12 +267,7 @@ mod tests {
268
267
269
268
let rapid_sync = RapidGossipSync :: new ( & network_graph) ;
270
269
let update_result = rapid_sync. update_network_graph ( & incremental_update_input[ ..] ) ;
271
- assert ! ( update_result. is_err( ) ) ;
272
- if let Err ( GraphSyncError :: LightningError ( lightning_error) ) = update_result {
273
- assert_eq ! ( lightning_error. err, "Couldn't find channel for update" ) ;
274
- } else {
275
- panic ! ( "Unexpected update result: {:?}" , update_result)
276
- }
270
+ assert ! ( update_result. is_ok( ) ) ;
277
271
}
278
272
279
273
#[ test]
0 commit comments