@@ -156,7 +156,10 @@ struct NodeInfo {
156
156
lowest_inbound_channel_fee_proportional_millionths : u32 ,
157
157
158
158
features : NodeFeatures ,
159
- last_update : u32 ,
159
+ /// Unlike for channels, we may have a NodeInfo entry before having received a node_update.
160
+ /// Thus, we have to be able to capture "no update has been received", which we do with an
161
+ /// Option here.
162
+ last_update : Option < u32 > ,
160
163
rgb : [ u8 ; 3 ] ,
161
164
alias : [ u8 ; 32 ] ,
162
165
addresses : Vec < NetAddress > ,
@@ -167,7 +170,7 @@ struct NodeInfo {
167
170
168
171
impl std:: fmt:: Display for NodeInfo {
169
172
fn fmt ( & self , f : & mut std:: fmt:: Formatter ) -> Result < ( ) , std:: fmt:: Error > {
170
- write ! ( f, "features: {}, last_update: {}, lowest_inbound_channel_fee_base_msat: {}, lowest_inbound_channel_fee_proportional_millionths: {}, channels: {:?}" , log_bytes!( self . features. encode( ) ) , self . last_update, self . lowest_inbound_channel_fee_base_msat, self . lowest_inbound_channel_fee_proportional_millionths, & self . channels[ ..] ) ?;
173
+ write ! ( f, "features: {}, last_update: {:? }, lowest_inbound_channel_fee_base_msat: {}, lowest_inbound_channel_fee_proportional_millionths: {}, channels: {:?}" , log_bytes!( self . features. encode( ) ) , self . last_update, self . lowest_inbound_channel_fee_base_msat, self . lowest_inbound_channel_fee_proportional_millionths, & self . channels[ ..] ) ?;
171
174
Ok ( ( ) )
172
175
}
173
176
}
@@ -418,12 +421,15 @@ impl RoutingMessageHandler for Router {
418
421
match network. nodes . get_mut ( & msg. contents . node_id ) {
419
422
None => Err ( LightningError { err : "No existing channels for node_announcement" , action : ErrorAction :: IgnoreError } ) ,
420
423
Some ( node) => {
421
- if node. last_update >= msg. contents . timestamp {
422
- return Err ( LightningError { err : "Update older than last processed update" , action : ErrorAction :: IgnoreError } ) ;
424
+ match node. last_update {
425
+ Some ( last_update) => if last_update >= msg. contents . timestamp {
426
+ return Err ( LightningError { err : "Update older than last processed update" , action : ErrorAction :: IgnoreError } ) ;
427
+ } ,
428
+ None => { } ,
423
429
}
424
430
425
431
node. features = msg. contents . features . clone ( ) ;
426
- node. last_update = msg. contents . timestamp ;
432
+ node. last_update = Some ( msg. contents . timestamp ) ;
427
433
node. rgb = msg. contents . rgb ;
428
434
node. alias = msg. contents . alias ;
429
435
node. addresses = msg. contents . addresses . clone ( ) ;
@@ -539,7 +545,7 @@ impl RoutingMessageHandler for Router {
539
545
lowest_inbound_channel_fee_base_msat: u32 :: max_value( ) ,
540
546
lowest_inbound_channel_fee_proportional_millionths: u32 :: max_value( ) ,
541
547
features: NodeFeatures :: empty( ) ,
542
- last_update: 0 ,
548
+ last_update: None ,
543
549
rgb: [ 0 ; 3 ] ,
544
550
alias: [ 0 ; 32 ] ,
545
551
addresses: Vec :: new( ) ,
@@ -752,7 +758,7 @@ impl Router {
752
758
lowest_inbound_channel_fee_base_msat : u32:: max_value ( ) ,
753
759
lowest_inbound_channel_fee_proportional_millionths : u32:: max_value ( ) ,
754
760
features : NodeFeatures :: empty ( ) ,
755
- last_update : 0 ,
761
+ last_update : None ,
756
762
rgb : [ 0 ; 3 ] ,
757
763
alias : [ 0 ; 32 ] ,
758
764
addresses : Vec :: new ( ) ,
@@ -1175,7 +1181,7 @@ mod tests {
1175
1181
lowest_inbound_channel_fee_base_msat : 100 ,
1176
1182
lowest_inbound_channel_fee_proportional_millionths : 0 ,
1177
1183
features : NodeFeatures :: from_le_bytes ( id_to_feature_flags ! ( 1 ) ) ,
1178
- last_update : 1 ,
1184
+ last_update : Some ( 1 ) ,
1179
1185
rgb : [ 0 ; 3 ] ,
1180
1186
alias : [ 0 ; 32 ] ,
1181
1187
addresses : Vec :: new ( ) ,
@@ -1209,7 +1215,7 @@ mod tests {
1209
1215
lowest_inbound_channel_fee_base_msat : 0 ,
1210
1216
lowest_inbound_channel_fee_proportional_millionths : 0 ,
1211
1217
features : NodeFeatures :: from_le_bytes ( id_to_feature_flags ! ( 2 ) ) ,
1212
- last_update : 1 ,
1218
+ last_update : Some ( 1 ) ,
1213
1219
rgb : [ 0 ; 3 ] ,
1214
1220
alias : [ 0 ; 32 ] ,
1215
1221
addresses : Vec :: new ( ) ,
@@ -1243,7 +1249,7 @@ mod tests {
1243
1249
lowest_inbound_channel_fee_base_msat : 0 ,
1244
1250
lowest_inbound_channel_fee_proportional_millionths : 0 ,
1245
1251
features : NodeFeatures :: from_le_bytes ( id_to_feature_flags ! ( 8 ) ) ,
1246
- last_update : 1 ,
1252
+ last_update : Some ( 1 ) ,
1247
1253
rgb : [ 0 ; 3 ] ,
1248
1254
alias : [ 0 ; 32 ] ,
1249
1255
addresses : Vec :: new ( ) ,
@@ -1283,7 +1289,7 @@ mod tests {
1283
1289
lowest_inbound_channel_fee_base_msat : 0 ,
1284
1290
lowest_inbound_channel_fee_proportional_millionths : 0 ,
1285
1291
features : NodeFeatures :: from_le_bytes ( id_to_feature_flags ! ( 3 ) ) ,
1286
- last_update : 1 ,
1292
+ last_update : Some ( 1 ) ,
1287
1293
rgb : [ 0 ; 3 ] ,
1288
1294
alias : [ 0 ; 32 ] ,
1289
1295
addresses : Vec :: new ( ) ,
@@ -1363,7 +1369,7 @@ mod tests {
1363
1369
lowest_inbound_channel_fee_base_msat : 0 ,
1364
1370
lowest_inbound_channel_fee_proportional_millionths : 0 ,
1365
1371
features : NodeFeatures :: from_le_bytes ( id_to_feature_flags ! ( 4 ) ) ,
1366
- last_update : 1 ,
1372
+ last_update : Some ( 1 ) ,
1367
1373
rgb : [ 0 ; 3 ] ,
1368
1374
alias : [ 0 ; 32 ] ,
1369
1375
addresses : Vec :: new ( ) ,
@@ -1397,7 +1403,7 @@ mod tests {
1397
1403
lowest_inbound_channel_fee_base_msat : 0 ,
1398
1404
lowest_inbound_channel_fee_proportional_millionths : 0 ,
1399
1405
features : NodeFeatures :: from_le_bytes ( id_to_feature_flags ! ( 5 ) ) ,
1400
- last_update : 1 ,
1406
+ last_update : Some ( 1 ) ,
1401
1407
rgb : [ 0 ; 3 ] ,
1402
1408
alias : [ 0 ; 32 ] ,
1403
1409
addresses : Vec :: new ( ) ,
@@ -1454,7 +1460,7 @@ mod tests {
1454
1460
lowest_inbound_channel_fee_base_msat : 0 ,
1455
1461
lowest_inbound_channel_fee_proportional_millionths : 0 ,
1456
1462
features : NodeFeatures :: from_le_bytes ( id_to_feature_flags ! ( 6 ) ) ,
1457
- last_update : 1 ,
1463
+ last_update : Some ( 1 ) ,
1458
1464
rgb : [ 0 ; 3 ] ,
1459
1465
alias : [ 0 ; 32 ] ,
1460
1466
addresses : Vec :: new ( ) ,
0 commit comments