@@ -517,37 +517,6 @@ impl<Descriptor: SocketDescriptor, CM: Deref> PeerManager<Descriptor, CM> where
517
517
}
518
518
}
519
519
520
- macro_rules! try_potential_decodeerror {
521
- ( $thing: expr) => {
522
- match $thing {
523
- Ok ( x) => x,
524
- Err ( e) => {
525
- match e {
526
- msgs:: DecodeError :: UnknownVersion => return Err ( PeerHandleError { no_connection_possible: false } ) ,
527
- msgs:: DecodeError :: UnknownRequiredFeature => {
528
- log_debug!( self , "Got a channel/node announcement with an known required feature flag, you may want to update!" ) ;
529
- continue ;
530
- } ,
531
- msgs:: DecodeError :: InvalidValue => {
532
- log_debug!( self , "Got an invalid value while deserializing message" ) ;
533
- return Err ( PeerHandleError { no_connection_possible: false } ) ;
534
- } ,
535
- msgs:: DecodeError :: ShortRead => {
536
- log_debug!( self , "Deserialization failed due to shortness of message" ) ;
537
- return Err ( PeerHandleError { no_connection_possible: false } ) ;
538
- } ,
539
- msgs:: DecodeError :: ExtraAddressesPerType => {
540
- log_debug!( self , "Error decoding message, ignoring due to lnd spec incompatibility. See https://github.com/lightningnetwork/lnd/issues/1407" ) ;
541
- continue ;
542
- } ,
543
- msgs:: DecodeError :: BadLengthDescriptor => return Err ( PeerHandleError { no_connection_possible: false } ) ,
544
- msgs:: DecodeError :: Io ( _) => return Err ( PeerHandleError { no_connection_possible: false } ) ,
545
- }
546
- }
547
- } ;
548
- }
549
- }
550
-
551
520
macro_rules! insert_node_id {
552
521
( ) => {
553
522
match peers. node_id_to_descriptor. entry( peer. their_node_id. unwrap( ) ) {
@@ -613,7 +582,34 @@ impl<Descriptor: SocketDescriptor, CM: Deref> PeerManager<Descriptor, CM> where
613
582
peer. pending_read_is_header = true ;
614
583
615
584
let mut reader = :: std:: io:: Cursor :: new ( & msg_data[ ..] ) ;
616
- let message = try_potential_decodeerror ! ( wire:: read( & mut reader) ) ;
585
+ let message_result = wire:: read ( & mut reader) ;
586
+ let message = match message_result {
587
+ Ok ( x) => x,
588
+ Err ( e) => {
589
+ match e {
590
+ msgs:: DecodeError :: UnknownVersion => return Err ( PeerHandleError { no_connection_possible : false } ) ,
591
+ msgs:: DecodeError :: UnknownRequiredFeature => {
592
+ log_debug ! ( self , "Got a channel/node announcement with an known required feature flag, you may want to update!" ) ;
593
+ continue ;
594
+ }
595
+ msgs:: DecodeError :: InvalidValue => {
596
+ log_debug ! ( self , "Got an invalid value while deserializing message" ) ;
597
+ return Err ( PeerHandleError { no_connection_possible : false } ) ;
598
+ }
599
+ msgs:: DecodeError :: ShortRead => {
600
+ log_debug ! ( self , "Deserialization failed due to shortness of message" ) ;
601
+ return Err ( PeerHandleError { no_connection_possible : false } ) ;
602
+ }
603
+ msgs:: DecodeError :: ExtraAddressesPerType => {
604
+ log_debug ! ( self , "Error decoding message, ignoring due to lnd spec incompatibility. See https://github.com/lightningnetwork/lnd/issues/1407" ) ;
605
+ continue ;
606
+ }
607
+ msgs:: DecodeError :: BadLengthDescriptor => return Err ( PeerHandleError { no_connection_possible : false } ) ,
608
+ msgs:: DecodeError :: Io ( _) => return Err ( PeerHandleError { no_connection_possible : false } ) ,
609
+ }
610
+ }
611
+ } ;
612
+
617
613
log_trace ! ( self , "Received message of type {} from {}" , message. type_id( ) , log_pubkey!( peer. their_node_id. unwrap( ) ) ) ;
618
614
619
615
// Need an Init as first message
0 commit comments