@@ -194,7 +194,13 @@ impl<NG: Deref<Target=NetworkGraph<L>>, L: Deref> RapidGossipSync<NG, L> where L
194
194
synthetic_update. htlc_maximum_msat = htlc_maximum_msat;
195
195
}
196
196
197
- network_graph. update_channel_unsigned ( & synthetic_update) ?;
197
+ match network_graph. update_channel_unsigned ( & synthetic_update) {
198
+ Ok ( _) => { } ,
199
+ Err ( LightningError { action : ErrorAction :: IgnoreDuplicateGossip , .. } ) => { } ,
200
+ Err ( LightningError { action : ErrorAction :: IgnoreAndLog ( _) , .. } ) => { } ,
201
+ Err ( LightningError { action : ErrorAction :: IgnoreError , .. } ) => { } ,
202
+ Err ( e) => return Err ( e. into ( ) ) ,
203
+ }
198
204
}
199
205
200
206
self . network_graph . set_last_rapid_gossip_sync_timestamp ( latest_seen_timestamp) ;
@@ -435,6 +441,50 @@ mod tests {
435
441
assert ! ( after. contains( "783241506229452801" ) ) ;
436
442
}
437
443
444
+ #[ test]
445
+ fn update_succeeds_when_duplicate_gossip_is_applied ( ) {
446
+ let initialization_input = vec ! [
447
+ 76 , 68 , 75 , 1 , 111 , 226 , 140 , 10 , 182 , 241 , 179 , 114 , 193 , 166 , 162 , 70 , 174 , 99 , 247 ,
448
+ 79 , 147 , 30 , 131 , 101 , 225 , 90 , 8 , 156 , 104 , 214 , 25 , 0 , 0 , 0 , 0 , 0 , 97 , 227 , 98 , 218 ,
449
+ 0 , 0 , 0 , 4 , 2 , 22 , 7 , 207 , 206 , 25 , 164 , 197 , 231 , 230 , 231 , 56 , 102 , 61 , 250 , 251 ,
450
+ 187 , 172 , 38 , 46 , 79 , 247 , 108 , 44 , 155 , 48 , 219 , 238 , 252 , 53 , 192 , 6 , 67 , 2 , 36 , 125 ,
451
+ 157 , 176 , 223 , 175 , 234 , 116 , 94 , 248 , 201 , 225 , 97 , 235 , 50 , 47 , 115 , 172 , 63 , 136 ,
452
+ 88 , 216 , 115 , 11 , 111 , 217 , 114 , 84 , 116 , 124 , 231 , 107 , 2 , 158 , 1 , 242 , 121 , 152 , 106 ,
453
+ 204 , 131 , 186 , 35 , 93 , 70 , 216 , 10 , 237 , 224 , 183 , 89 , 95 , 65 , 3 , 83 , 185 , 58 , 138 ,
454
+ 181 , 64 , 187 , 103 , 127 , 68 , 50 , 2 , 201 , 19 , 17 , 138 , 136 , 149 , 185 , 226 , 156 , 137 , 175 ,
455
+ 110 , 32 , 237 , 0 , 217 , 90 , 31 , 100 , 228 , 149 , 46 , 219 , 175 , 168 , 77 , 4 , 143 , 38 , 128 ,
456
+ 76 , 97 , 0 , 0 , 0 , 2 , 0 , 0 , 255 , 8 , 153 , 192 , 0 , 2 , 27 , 0 , 0 , 0 , 1 , 0 , 0 , 255 , 2 , 68 ,
457
+ 226 , 0 , 6 , 11 , 0 , 1 , 2 , 3 , 0 , 0 , 0 , 4 , 0 , 40 , 0 , 0 , 0 , 0 , 0 , 0 , 3 , 232 , 0 , 0 , 3 , 232 ,
458
+ 0 , 0 , 0 , 1 , 0 , 0 , 0 , 0 , 58 , 85 , 116 , 216 , 255 , 8 , 153 , 192 , 0 , 2 , 27 , 0 , 0 , 56 , 0 , 0 ,
459
+ 0 , 0 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 100 , 0 , 0 , 2 , 224 , 0 , 25 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 125 , 255 , 2 ,
460
+ 68 , 226 , 0 , 6 , 11 , 0 , 1 , 4 , 0 , 0 , 0 , 0 , 29 , 129 , 25 , 192 , 0 , 5 , 0 , 0 , 0 , 0 , 29 , 129 ,
461
+ 25 , 192 ,
462
+ ] ;
463
+
464
+ let block_hash = genesis_block ( Network :: Bitcoin ) . block_hash ( ) ;
465
+ let logger = TestLogger :: new ( ) ;
466
+ let network_graph = NetworkGraph :: new ( block_hash, & logger) ;
467
+
468
+ assert_eq ! ( network_graph. read_only( ) . channels( ) . len( ) , 0 ) ;
469
+
470
+ let rapid_sync = RapidGossipSync :: new ( & network_graph) ;
471
+ let initialization_result = rapid_sync. update_network_graph ( & initialization_input[ ..] ) ;
472
+ assert ! ( initialization_result. is_ok( ) ) ;
473
+
474
+ let single_direction_incremental_update_input = vec ! [
475
+ 76 , 68 , 75 , 1 , 111 , 226 , 140 , 10 , 182 , 241 , 179 , 114 , 193 , 166 , 162 , 70 , 174 , 99 , 247 ,
476
+ 79 , 147 , 30 , 131 , 101 , 225 , 90 , 8 , 156 , 104 , 214 , 25 , 0 , 0 , 0 , 0 , 0 , 97 , 229 , 183 , 167 ,
477
+ 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 2 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
478
+ 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 ,
479
+ 68 , 226 , 0 , 6 , 11 , 0 , 1 , 128 ,
480
+ ] ;
481
+ let update_result_1 = rapid_sync. update_network_graph ( & single_direction_incremental_update_input[ ..] ) ;
482
+ // Apply duplicate update
483
+ let update_result_2 = rapid_sync. update_network_graph ( & single_direction_incremental_update_input[ ..] ) ;
484
+ assert ! ( update_result_1. is_ok( ) ) ;
485
+ assert ! ( update_result_2. is_ok( ) ) ;
486
+ }
487
+
438
488
#[ test]
439
489
fn full_update_succeeds ( ) {
440
490
let valid_input = vec ! [
0 commit comments