@@ -410,8 +410,8 @@ where L::Target: Logger {
410410 chacha. process ( & packet_decrypted, & mut decryption_tmp[ ..] ) ;
411411 packet_decrypted = decryption_tmp;
412412
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).
415415 is_from_final_node = route_hop_idx + 1 == path. hops . len ( ) ;
416416 let failing_route_hop = if is_from_final_node { route_hop } else { & path. hops [ route_hop_idx + 1 ] } ;
417417
@@ -427,8 +427,8 @@ where L::Target: Logger {
427427 let error_code_slice = match err_packet. failuremsg . get ( 0 ..2 ) {
428428 Some ( s) => s,
429429 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
432432 let network_update = Some ( NetworkUpdate :: NodeFailure {
433433 node_id : route_hop. pubkey ,
434434 is_permanent : true ,
@@ -449,8 +449,7 @@ where L::Target: Logger {
449449
450450 let ( debug_field, debug_field_size) = errors:: get_onion_debug_field ( error_code) ;
451451
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
454453 let payment_failed = match error_code & 0xff {
455454 15 |16 |17 |18 |19 |23 => true ,
456455 _ => false ,
@@ -460,14 +459,13 @@ where L::Target: Logger {
460459 let mut short_channel_id = None ;
461460
462461 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.
471469 network_update = Some ( NetworkUpdate :: ChannelFailure {
472470 short_channel_id : failing_route_hop. short_channel_id ,
473471 is_permanent : true ,
@@ -493,14 +491,11 @@ where L::Target: Logger {
493491 err_packet. failuremsg . get ( debug_field_size + 4 ..debug_field_size + 4 + l as usize )
494492 } )
495493 . 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
504499 // happen to start with ChannelUpdate::TYPE, i.e., [0x01, 0x02].
505500 if update_slice. len ( ) > 2 && update_slice[ 0 ..2 ] == msgs:: ChannelUpdate :: TYPE . to_be_bytes ( ) {
506501 update_slice = & update_slice[ 2 ..] ;
@@ -509,9 +504,8 @@ where L::Target: Logger {
509504 }
510505 let update_opt = msgs:: ChannelUpdate :: read ( & mut Cursor :: new ( & update_slice) ) ;
511506 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.
515509 log_info ! ( logger, "Failed to read a channel_update of len {} in an onion" ,
516510 update_slice. len( ) ) ;
517511 }
@@ -538,15 +532,14 @@ where L::Target: Logger {
538532 _ => false , // unknown error code; take channel_update as valid
539533 } ;
540534 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.
543537 network_update = Some ( NetworkUpdate :: ChannelFailure {
544538 short_channel_id : route_hop. short_channel_id ,
545539 is_permanent : true ,
546540 } ) ;
547541 } 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.
550543 if failing_route_hop. short_channel_id == chan_update. contents . short_channel_id {
551544 short_channel_id = Some ( failing_route_hop. short_channel_id ) ;
552545 } else {
@@ -562,8 +555,8 @@ where L::Target: Logger {
562555 } ) ;
563556 } ;
564557 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.
567560 network_update = Some ( NetworkUpdate :: NodeFailure {
568561 node_id : route_hop. pubkey ,
569562 is_permanent : true ,
@@ -573,16 +566,15 @@ where L::Target: Logger {
573566 short_channel_id = Some ( route_hop. short_channel_id ) ;
574567 }
575568 } 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.
578571 short_channel_id = match error_code & 0xff {
579572 18 |19 => Some ( route_hop. short_channel_id ) ,
580573 _ => None ,
581574 } ;
582575 } 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.
586578 network_update = Some ( NetworkUpdate :: NodeFailure {
587579 node_id : route_hop. pubkey ,
588580 is_permanent : true ,
0 commit comments