@@ -10,6 +10,7 @@ use lightning::ln::msgs::{
10
10
} ;
11
11
use lightning:: routing:: gossip:: NetworkGraph ;
12
12
use lightning:: util:: logger:: Logger ;
13
+ use lightning:: { log_warn, log_trace, log_given_level} ;
13
14
use lightning:: util:: ser:: { BigSize , Readable } ;
14
15
use lightning:: io;
15
16
@@ -120,6 +121,7 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
120
121
if let ErrorAction :: IgnoreDuplicateGossip = lightning_error. action {
121
122
// everything is fine, just a duplicate channel announcement
122
123
} else {
124
+ log_warn ! ( self . logger, "Failed to process channel announcement: {:?}" , lightning_error) ;
123
125
return Err ( lightning_error. into ( ) ) ;
124
126
}
125
127
}
@@ -169,24 +171,19 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
169
171
if ( channel_flags & 0b_1000_0000 ) != 0 {
170
172
// incremental update, field flags will indicate mutated values
171
173
let read_only_network_graph = network_graph. read_only ( ) ;
172
- if let Some ( channel) = read_only_network_graph
173
- . channels ( )
174
- . get ( & short_channel_id) {
175
-
176
- let directional_info = channel
177
- . get_directional_info ( channel_flags)
178
- . ok_or ( LightningError {
179
- err : "Couldn't find previous directional data for update" . to_owned ( ) ,
180
- action : ErrorAction :: IgnoreError ,
181
- } ) ?;
182
-
174
+ if let Some ( directional_info) =
175
+ read_only_network_graph. channels ( ) . get ( & short_channel_id)
176
+ . and_then ( |channel| channel. get_directional_info ( channel_flags) )
177
+ {
183
178
synthetic_update. cltv_expiry_delta = directional_info. cltv_expiry_delta ;
184
179
synthetic_update. htlc_minimum_msat = directional_info. htlc_minimum_msat ;
185
180
synthetic_update. htlc_maximum_msat = directional_info. htlc_maximum_msat ;
186
181
synthetic_update. fee_base_msat = directional_info. fees . base_msat ;
187
182
synthetic_update. fee_proportional_millionths = directional_info. fees . proportional_millionths ;
188
-
189
183
} else {
184
+ log_trace ! ( self . logger,
185
+ "Skipping application of channel update for chan {} with flags {} as original data is missing." ,
186
+ short_channel_id, channel_flags) ;
190
187
skip_update_for_unknown_channel = true ;
191
188
}
192
189
} ;
@@ -223,7 +220,9 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
223
220
match network_graph. update_channel_unsigned ( & synthetic_update) {
224
221
Ok ( _) => { } ,
225
222
Err ( LightningError { action : ErrorAction :: IgnoreDuplicateGossip , .. } ) => { } ,
226
- Err ( LightningError { action : ErrorAction :: IgnoreAndLog ( _) , .. } ) => { } ,
223
+ Err ( LightningError { action : ErrorAction :: IgnoreAndLog ( level) , err } ) => {
224
+ log_given_level ! ( self . logger, level, "Failed to apply channel update: {:?}" , err) ;
225
+ } ,
227
226
Err ( LightningError { action : ErrorAction :: IgnoreError , .. } ) => { } ,
228
227
Err ( e) => return Err ( e. into ( ) ) ,
229
228
}
@@ -287,7 +286,7 @@ mod tests {
287
286
0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 58 , 85 , 116 , 216 , 255 , 2 , 68 , 226 , 0 , 6 , 11 , 0 , 1 , 24 , 0 ,
288
287
0 , 3 , 232 , 0 , 0 , 0 ,
289
288
] ;
290
- let rapid_sync = RapidGossipSync :: new ( & network_graph) ;
289
+ let rapid_sync = RapidGossipSync :: new ( & network_graph, & logger ) ;
291
290
let update_result = rapid_sync. update_network_graph ( & example_input[ ..] ) ;
292
291
assert ! ( update_result. is_err( ) ) ;
293
292
if let Err ( GraphSyncError :: DecodeError ( DecodeError :: ShortRead ) ) = update_result {
@@ -312,7 +311,7 @@ mod tests {
312
311
313
312
assert_eq ! ( network_graph. read_only( ) . channels( ) . len( ) , 0 ) ;
314
313
315
- let rapid_sync = RapidGossipSync :: new ( & network_graph) ;
314
+ let rapid_sync = RapidGossipSync :: new ( & network_graph, & logger ) ;
316
315
let update_result = rapid_sync. update_network_graph ( & incremental_update_input[ ..] ) ;
317
316
assert ! ( update_result. is_ok( ) ) ;
318
317
}
@@ -340,17 +339,8 @@ mod tests {
340
339
341
340
assert_eq ! ( network_graph. read_only( ) . channels( ) . len( ) , 0 ) ;
342
341
343
- let rapid_sync = RapidGossipSync :: new ( & network_graph) ;
344
- let update_result = rapid_sync. update_network_graph ( & announced_update_input[ ..] ) ;
345
- assert ! ( update_result. is_err( ) ) ;
346
- if let Err ( GraphSyncError :: LightningError ( lightning_error) ) = update_result {
347
- assert_eq ! (
348
- lightning_error. err,
349
- "Couldn't find previous directional data for update"
350
- ) ;
351
- } else {
352
- panic ! ( "Unexpected update result: {:?}" , update_result)
353
- }
342
+ let rapid_sync = RapidGossipSync :: new ( & network_graph, & logger) ;
343
+ rapid_sync. update_network_graph ( & announced_update_input[ ..] ) . unwrap ( ) ;
354
344
}
355
345
356
346
#[ test]
@@ -376,7 +366,7 @@ mod tests {
376
366
377
367
assert_eq ! ( network_graph. read_only( ) . channels( ) . len( ) , 0 ) ;
378
368
379
- let rapid_sync = RapidGossipSync :: new ( & network_graph) ;
369
+ let rapid_sync = RapidGossipSync :: new ( & network_graph, & logger ) ;
380
370
let initialization_result = rapid_sync. update_network_graph ( & initialization_input[ ..] ) ;
381
371
if initialization_result. is_err ( ) {
382
372
panic ! (
@@ -405,16 +395,7 @@ mod tests {
405
395
0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 255 , 8 , 153 , 192 , 0 , 2 , 27 , 0 , 0 , 136 , 0 , 0 , 0 , 221 , 255 , 2 ,
406
396
68 , 226 , 0 , 6 , 11 , 0 , 1 , 128 ,
407
397
] ;
408
- let update_result = rapid_sync. update_network_graph ( & opposite_direction_incremental_update_input[ ..] ) ;
409
- assert ! ( update_result. is_err( ) ) ;
410
- if let Err ( GraphSyncError :: LightningError ( lightning_error) ) = update_result {
411
- assert_eq ! (
412
- lightning_error. err,
413
- "Couldn't find previous directional data for update"
414
- ) ;
415
- } else {
416
- panic ! ( "Unexpected update result: {:?}" , update_result)
417
- }
398
+ rapid_sync. update_network_graph ( & opposite_direction_incremental_update_input[ ..] ) . unwrap ( ) ;
418
399
}
419
400
420
401
#[ test]
@@ -442,7 +423,7 @@ mod tests {
442
423
443
424
assert_eq ! ( network_graph. read_only( ) . channels( ) . len( ) , 0 ) ;
444
425
445
- let rapid_sync = RapidGossipSync :: new ( & network_graph) ;
426
+ let rapid_sync = RapidGossipSync :: new ( & network_graph, & logger ) ;
446
427
let initialization_result = rapid_sync. update_network_graph ( & initialization_input[ ..] ) ;
447
428
assert ! ( initialization_result. is_ok( ) ) ;
448
429
@@ -501,7 +482,7 @@ mod tests {
501
482
502
483
assert_eq ! ( network_graph. read_only( ) . channels( ) . len( ) , 0 ) ;
503
484
504
- let rapid_sync = RapidGossipSync :: new ( & network_graph) ;
485
+ let rapid_sync = RapidGossipSync :: new ( & network_graph, & logger ) ;
505
486
let initialization_result = rapid_sync. update_network_graph ( & initialization_input[ ..] ) ;
506
487
assert ! ( initialization_result. is_ok( ) ) ;
507
488
@@ -526,7 +507,7 @@ mod tests {
526
507
527
508
assert_eq ! ( network_graph. read_only( ) . channels( ) . len( ) , 0 ) ;
528
509
529
- let rapid_sync = RapidGossipSync :: new ( & network_graph) ;
510
+ let rapid_sync = RapidGossipSync :: new ( & network_graph, & logger ) ;
530
511
let update_result = rapid_sync. update_network_graph ( & VALID_RGS_BINARY ) ;
531
512
if update_result. is_err ( ) {
532
513
panic ! ( "Unexpected update result: {:?}" , update_result)
@@ -557,7 +538,7 @@ mod tests {
557
538
558
539
assert_eq ! ( network_graph. read_only( ) . channels( ) . len( ) , 0 ) ;
559
540
560
- let rapid_sync = RapidGossipSync :: new ( & network_graph) ;
541
+ let rapid_sync = RapidGossipSync :: new ( & network_graph, & logger ) ;
561
542
// this is mostly for checking uint underflow issues before the fuzzer does
562
543
let update_result = rapid_sync. update_network_graph_no_std ( & VALID_RGS_BINARY , Some ( 0 ) ) ;
563
544
assert ! ( update_result. is_ok( ) ) ;
@@ -576,7 +557,7 @@ mod tests {
576
557
let network_graph = NetworkGraph :: new ( Network :: Bitcoin , & logger) ;
577
558
assert_eq ! ( network_graph. read_only( ) . channels( ) . len( ) , 0 ) ;
578
559
579
- let rapid_sync = RapidGossipSync :: new ( & network_graph) ;
560
+ let rapid_sync = RapidGossipSync :: new ( & network_graph, & logger ) ;
580
561
let update_result = rapid_sync. update_network_graph_no_std ( & VALID_RGS_BINARY , Some ( latest_succeeding_time) ) ;
581
562
assert ! ( update_result. is_ok( ) ) ;
582
563
assert_eq ! ( network_graph. read_only( ) . channels( ) . len( ) , 2 ) ;
@@ -586,7 +567,7 @@ mod tests {
586
567
let network_graph = NetworkGraph :: new ( Network :: Bitcoin , & logger) ;
587
568
assert_eq ! ( network_graph. read_only( ) . channels( ) . len( ) , 0 ) ;
588
569
589
- let rapid_sync = RapidGossipSync :: new ( & network_graph) ;
570
+ let rapid_sync = RapidGossipSync :: new ( & network_graph, & logger ) ;
590
571
let update_result = rapid_sync. update_network_graph_no_std ( & VALID_RGS_BINARY , Some ( earliest_failing_time) ) ;
591
572
assert ! ( update_result. is_err( ) ) ;
592
573
if let Err ( GraphSyncError :: LightningError ( lightning_error) ) = update_result {
@@ -622,7 +603,7 @@ mod tests {
622
603
623
604
let logger = TestLogger :: new ( ) ;
624
605
let network_graph = NetworkGraph :: new ( Network :: Bitcoin , & logger) ;
625
- let rapid_sync = RapidGossipSync :: new ( & network_graph) ;
606
+ let rapid_sync = RapidGossipSync :: new ( & network_graph, & logger ) ;
626
607
let update_result = rapid_sync. update_network_graph ( & unknown_version_input[ ..] ) ;
627
608
628
609
assert ! ( update_result. is_err( ) ) ;
0 commit comments