@@ -410,8 +410,8 @@ where L::Target: Logger {
410
410
chacha. process ( & packet_decrypted, & mut decryption_tmp[ ..] ) ;
411
411
packet_decrypted = decryption_tmp;
412
412
413
- // The failing hop includes either the inbound channel to the recipient or the outbound
414
- // channel from the current hop (i.e., the next hop's inbound channel).
413
+ // The failing hop includes either the inbound channel to the recipient or the outbound channel
414
+ // from the current hop (i.e., the next hop's inbound channel).
415
415
is_from_final_node = route_hop_idx + 1 == path. hops . len ( ) ;
416
416
let failing_route_hop = if is_from_final_node { route_hop } else { & path. hops [ route_hop_idx + 1 ] } ;
417
417
@@ -427,8 +427,8 @@ where L::Target: Logger {
427
427
let error_code_slice = match err_packet. failuremsg . get ( 0 ..2 ) {
428
428
Some ( s) => s,
429
429
None => {
430
- // Useless packet that we can't use but it passed HMAC, so it
431
- // definitely came from the peer in question
430
+ // Useless packet that we can't use but it passed HMAC, so it definitely came from the peer
431
+ // in question
432
432
let network_update = Some ( NetworkUpdate :: NodeFailure {
433
433
node_id : route_hop. pubkey ,
434
434
is_permanent : true ,
@@ -449,8 +449,7 @@ where L::Target: Logger {
449
449
450
450
let ( debug_field, debug_field_size) = errors:: get_onion_debug_field ( error_code) ;
451
451
452
- // indicate that payment parameter has failed and no need to
453
- // update Route object
452
+ // indicate that payment parameter has failed and no need to update Route object
454
453
let payment_failed = match error_code & 0xff {
455
454
15 |16 |17 |18 |19 |23 => true ,
456
455
_ => false ,
@@ -460,14 +459,13 @@ where L::Target: Logger {
460
459
let mut short_channel_id = None ;
461
460
462
461
if error_code & BADONION == BADONION {
463
- // If the error code has the BADONION bit set, always blame the channel
464
- // from the node "originating" the error to its next hop. The
465
- // "originator" is ultimately actually claiming that its counterparty
466
- // is the one who is failing the HTLC.
467
- // If the "originator" here isn't lying we should really mark the
468
- // next-hop node as failed entirely, but we can't be confident in that,
469
- // as it would allow any node to get us to completely ban one of its
470
- // counterparties. Instead, we simply remove the channel in question.
462
+ // If the error code has the BADONION bit set, always blame the channel from the node
463
+ // "originating" the error to its next hop. The "originator" is ultimately actually claiming
464
+ // that its counterparty is the one who is failing the HTLC.
465
+ // If the "originator" here isn't lying we should really mark the next-hop node as failed
466
+ // entirely, but we can't be confident in that, as it would allow any node to get us to
467
+ // completely ban one of its counterparties. Instead, we simply remove the channel in
468
+ // question.
471
469
network_update = Some ( NetworkUpdate :: ChannelFailure {
472
470
short_channel_id : failing_route_hop. short_channel_id ,
473
471
is_permanent : true ,
@@ -493,14 +491,11 @@ where L::Target: Logger {
493
491
err_packet. failuremsg . get ( debug_field_size + 4 ..debug_field_size + 4 + l as usize )
494
492
} )
495
493
. unwrap_or ( & [ ] ) ;
496
- // Historically, the BOLTs were unclear if the message type
497
- // bytes should be included here or not. The BOLTs have now
498
- // been updated to indicate that they *are* included, but many
499
- // nodes still send messages without the type bytes, so we
500
- // support both here.
501
- // TODO: Switch to hard require the type prefix, as the current
502
- // permissiveness introduces the (although small) possibility
503
- // that we fail to decode legitimate channel updates that
494
+ // Historically, the BOLTs were unclear if the message type bytes should be included here or
495
+ // not. The BOLTs have now been updated to indicate that they *are* included, but many nodes
496
+ // still send messages without the type bytes, so we support both here.
497
+ // TODO: Switch to hard require the type prefix, as the current permissiveness introduces the
498
+ // (although small) possibility that we fail to decode legitimate channel updates that
504
499
// happen to start with ChannelUpdate::TYPE, i.e., [0x01, 0x02].
505
500
if update_slice. len ( ) > 2 && update_slice[ 0 ..2 ] == msgs:: ChannelUpdate :: TYPE . to_be_bytes ( ) {
506
501
update_slice = & update_slice[ 2 ..] ;
@@ -509,9 +504,8 @@ where L::Target: Logger {
509
504
}
510
505
let update_opt = msgs:: ChannelUpdate :: read ( & mut Cursor :: new ( & update_slice) ) ;
511
506
if update_present && !update_opt. is_ok ( ) {
512
- // If the channel_update had a non-zero length (i.e. was
513
- // present) but we couldn't read it, treat it as a total
514
- // node failure.
507
+ // If the channel_update had a non-zero length (i.e. was present) but we couldn't read it,
508
+ // treat it as a total node failure.
515
509
log_info ! ( logger, "Failed to read a channel_update of len {} in an onion" ,
516
510
update_slice. len( ) ) ;
517
511
}
@@ -538,15 +532,14 @@ where L::Target: Logger {
538
532
_ => false , // unknown error code; take channel_update as valid
539
533
} ;
540
534
if is_chan_update_invalid {
541
- // This probably indicates the node which forwarded
542
- // to the node in question corrupted something.
535
+ // This probably indicates the node which forwarded to the node in question corrupted
536
+ // something.
543
537
network_update = Some ( NetworkUpdate :: ChannelFailure {
544
538
short_channel_id : route_hop. short_channel_id ,
545
539
is_permanent : true ,
546
540
} ) ;
547
541
} else if let Ok ( chan_update) = update_opt {
548
- // Make sure the ChannelUpdate contains the expected
549
- // short channel id.
542
+ // Make sure the ChannelUpdate contains the expected short channel id.
550
543
if failing_route_hop. short_channel_id == chan_update. contents . short_channel_id {
551
544
short_channel_id = Some ( failing_route_hop. short_channel_id ) ;
552
545
} else {
@@ -562,8 +555,8 @@ where L::Target: Logger {
562
555
} ) ;
563
556
} ;
564
557
if network_update. is_none ( ) {
565
- // They provided an UPDATE which was obviously bogus, not worth
566
- // trying to relay through them anymore.
558
+ // They provided an UPDATE which was obviously bogus, not worth trying to relay through them
559
+ // anymore.
567
560
network_update = Some ( NetworkUpdate :: NodeFailure {
568
561
node_id : route_hop. pubkey ,
569
562
is_permanent : true ,
@@ -573,16 +566,15 @@ where L::Target: Logger {
573
566
short_channel_id = Some ( route_hop. short_channel_id ) ;
574
567
}
575
568
} else if payment_failed {
576
- // Only blame the hop when a value in the HTLC doesn't match the
577
- // corresponding value in the onion.
569
+ // Only blame the hop when a value in the HTLC doesn't match the corresponding value in the
570
+ // onion.
578
571
short_channel_id = match error_code & 0xff {
579
572
18 |19 => Some ( route_hop. short_channel_id ) ,
580
573
_ => None ,
581
574
} ;
582
575
} else {
583
- // We can't understand their error messages and they failed to
584
- // forward...they probably can't understand our forwards so its
585
- // really not worth trying any further.
576
+ // We can't understand their error messages and they failed to forward...they probably can't
577
+ // understand our forwards so it's really not worth trying any further.
586
578
network_update = Some ( NetworkUpdate :: NodeFailure {
587
579
node_id : route_hop. pubkey ,
588
580
is_permanent : true ,
0 commit comments