@@ -289,7 +289,10 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
289
289
290
290
macro_rules! encode_and_send_msg {
291
291
( $msg: expr, $msg_code: expr) => {
292
- peer. pending_outbound_buffer. push_back( peer. channel_encryptor. encrypt_message( & encode_msg!( $msg, $msg_code) [ ..] ) ) ;
292
+ {
293
+ log_trace!( self , "Encoding and sending message of type {} to {}" , $msg_code, log_pubkey!( peer. their_node_id. unwrap( ) ) ) ;
294
+ peer. pending_outbound_buffer. push_back( peer. channel_encryptor. encrypt_message( & encode_msg!( $msg, $msg_code) [ ..] ) ) ;
295
+ }
293
296
}
294
297
}
295
298
@@ -396,6 +399,7 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
396
399
peer. pending_read_is_header = true ;
397
400
398
401
let msg_type = byte_utils:: slice_to_be16 ( & msg_data[ 0 ..2 ] ) ;
402
+ log_trace ! ( self , "Received message of type {} from {}" , msg_type, log_pubkey!( peer. their_node_id. unwrap( ) ) ) ;
399
403
if msg_type != 16 && peer. their_global_features . is_none ( ) {
400
404
// Need an init message as first message
401
405
return Err ( PeerHandleError { no_connection_possible : false } ) ;
@@ -632,6 +636,9 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
632
636
Event :: PendingHTLCsForwardable { ..} => { /* Hand upstream */ } ,
633
637
634
638
Event :: SendOpenChannel { ref node_id, ref msg } => {
639
+ log_trace ! ( self , "Handling SendOpenChannel event in peer_handler for node {} for channel {}" ,
640
+ log_pubkey!( node_id) ,
641
+ log_bytes!( msg. temporary_channel_id) ) ;
635
642
let ( mut descriptor, peer) = get_peer_for_forwarding ! ( node_id, {
636
643
//TODO: Drop the pending channel? (or just let it timeout, but that sucks)
637
644
} ) ;
@@ -640,6 +647,10 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
640
647
continue ;
641
648
} ,
642
649
Event :: SendFundingCreated { ref node_id, ref msg } => {
650
+ log_trace ! ( self , "Handling SendFundingCreated event in peer_handler for node {} for channel {} (which becomes {})" ,
651
+ log_pubkey!( node_id) ,
652
+ log_bytes!( msg. temporary_channel_id) ,
653
+ log_funding_channel_id!( msg. funding_txid, msg. funding_output_index) ) ;
643
654
let ( mut descriptor, peer) = get_peer_for_forwarding ! ( node_id, {
644
655
//TODO: generate a DiscardFunding event indicating to the wallet that
645
656
//they should just throw away this funding transaction
@@ -649,6 +660,10 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
649
660
continue ;
650
661
} ,
651
662
Event :: SendFundingLocked { ref node_id, ref msg, ref announcement_sigs } => {
663
+ log_trace ! ( self , "Handling SendFundingLocked event in peer_handler for node {}{} for channel {}" ,
664
+ log_pubkey!( node_id) ,
665
+ if announcement_sigs. is_some( ) { " with announcement sigs" } else { "" } ,
666
+ log_bytes!( msg. channel_id) ) ;
652
667
let ( mut descriptor, peer) = get_peer_for_forwarding ! ( node_id, {
653
668
//TODO: Do whatever we're gonna do for handling dropped messages
654
669
} ) ;
@@ -661,6 +676,10 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
661
676
continue ;
662
677
} ,
663
678
Event :: SendHTLCs { ref node_id, ref msgs, ref commitment_msg } => {
679
+ log_trace ! ( self , "Handling SendHTLCs event in peer_handler for node {} with {} HTLCs for channel {}" ,
680
+ log_pubkey!( node_id) ,
681
+ msgs. len( ) ,
682
+ log_bytes!( commitment_msg. channel_id) ) ;
664
683
let ( mut descriptor, peer) = get_peer_for_forwarding ! ( node_id, {
665
684
//TODO: Do whatever we're gonna do for handling dropped messages
666
685
} ) ;
@@ -672,6 +691,10 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
672
691
continue ;
673
692
} ,
674
693
Event :: SendFulfillHTLC { ref node_id, ref msg, ref commitment_msg } => {
694
+ log_trace ! ( self , "Handling SendFulfillHTLCs event in peer_handler for node {} with payment_preimage {} for channel {}" ,
695
+ log_pubkey!( node_id) ,
696
+ log_bytes!( msg. payment_preimage) ,
697
+ log_bytes!( msg. channel_id) ) ;
675
698
let ( mut descriptor, peer) = get_peer_for_forwarding ! ( node_id, {
676
699
//TODO: Do whatever we're gonna do for handling dropped messages
677
700
} ) ;
@@ -681,6 +704,10 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
681
704
continue ;
682
705
} ,
683
706
Event :: SendFailHTLC { ref node_id, ref msg, ref commitment_msg } => {
707
+ log_trace ! ( self , "Handling SendFailHTLCs event in peer_handler for node {} for HTLC ID {} for channel {}" ,
708
+ log_pubkey!( node_id) ,
709
+ msg. htlc_id,
710
+ log_bytes!( msg. channel_id) ) ;
684
711
let ( mut descriptor, peer) = get_peer_for_forwarding ! ( node_id, {
685
712
//TODO: Do whatever we're gonna do for handling dropped messages
686
713
} ) ;
@@ -690,6 +717,9 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
690
717
continue ;
691
718
} ,
692
719
Event :: SendShutdown { ref node_id, ref msg } => {
720
+ log_trace ! ( self , "Handling Shutdown event in peer_handler for node {} for channel {}" ,
721
+ log_pubkey!( node_id) ,
722
+ log_bytes!( msg. channel_id) ) ;
693
723
let ( mut descriptor, peer) = get_peer_for_forwarding ! ( node_id, {
694
724
//TODO: Do whatever we're gonna do for handling dropped messages
695
725
} ) ;
@@ -698,6 +728,7 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
698
728
continue ;
699
729
} ,
700
730
Event :: BroadcastChannelAnnouncement { ref msg, ref update_msg } => {
731
+ log_trace ! ( self , "Handling BroadcastChannelAnnouncement event in peer_handler for short channel id {}" , msg. contents. short_channel_id) ;
701
732
if self . message_handler . route_handler . handle_channel_announcement ( msg) . is_ok ( ) && self . message_handler . route_handler . handle_channel_update ( update_msg) . is_ok ( ) {
702
733
let encoded_msg = encode_msg ! ( msg, 256 ) ;
703
734
let encoded_update_msg = encode_msg ! ( update_msg, 258 ) ;
@@ -722,6 +753,7 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
722
753
continue ;
723
754
} ,
724
755
Event :: BroadcastChannelUpdate { ref msg } => {
756
+ log_trace ! ( self , "Handling BroadcastChannelUpdate event in peer_handler for short channel id {}" , msg. contents. short_channel_id) ;
725
757
if self . message_handler . route_handler . handle_channel_update ( msg) . is_ok ( ) {
726
758
let encoded_msg = encode_msg ! ( msg, 258 ) ;
727
759
@@ -739,6 +771,10 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
739
771
if let Some ( ref action) = * action {
740
772
match * action {
741
773
msgs:: ErrorAction :: UpdateFailHTLC { ref msg } => {
774
+ log_trace ! ( self , "Handling UpdateFailHTLC HandleError event in peer_handler for node {} for HTLC ID {} for channel {}" ,
775
+ log_pubkey!( node_id) ,
776
+ msg. htlc_id,
777
+ log_bytes!( msg. channel_id) ) ;
742
778
let ( mut descriptor, peer) = get_peer_for_forwarding ! ( node_id, {
743
779
//TODO: Do whatever we're gonna do for handling dropped messages
744
780
} ) ;
@@ -750,10 +786,15 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
750
786
if let Some ( mut descriptor) = peers. node_id_to_descriptor . remove ( node_id) {
751
787
if let Some ( mut peer) = peers. peers . remove ( & descriptor) {
752
788
if let Some ( ref msg) = * msg {
789
+ log_trace ! ( self , "Handling DisconnectPeer HandleError event in peer_handler for node {} with message {}" ,
790
+ log_pubkey!( node_id) ,
791
+ msg. data) ;
753
792
peer. pending_outbound_buffer . push_back ( peer. channel_encryptor . encrypt_message ( & encode_msg ! ( msg, 17 ) ) ) ;
754
793
// This isn't guaranteed to work, but if there is enough free
755
794
// room in the send buffer, put the error message there...
756
795
Self :: do_attempt_write_data ( & mut descriptor, & mut peer) ;
796
+ } else {
797
+ log_trace ! ( self , "Handling DisconnectPeer HandleError event in peer_handler for node {} with no message" , log_pubkey!( node_id) ) ;
757
798
}
758
799
}
759
800
descriptor. disconnect_socket ( ) ;
@@ -764,13 +805,18 @@ impl<Descriptor: SocketDescriptor> PeerManager<Descriptor> {
764
805
continue ;
765
806
} ,
766
807
msgs:: ErrorAction :: SendErrorMessage { ref msg } => {
808
+ log_trace ! ( self , "Handling SendErrorMessage HandleError event in peer_handler for node {} with message {}" ,
809
+ log_pubkey!( node_id) ,
810
+ msg. data) ;
767
811
let ( mut descriptor, peer) = get_peer_for_forwarding ! ( node_id, {
768
812
//TODO: Do whatever we're gonna do for handling dropped messages
769
813
} ) ;
770
814
peer. pending_outbound_buffer . push_back ( peer. channel_encryptor . encrypt_message ( & encode_msg ! ( msg, 17 ) ) ) ;
771
815
Self :: do_attempt_write_data ( & mut descriptor, peer) ;
772
816
} ,
773
817
}
818
+ } else {
819
+ log_error ! ( self , "Got no-action HandleError Event in peer_handler for node {}, no such events should ever be generated!" , log_pubkey!( node_id) ) ;
774
820
}
775
821
continue ;
776
822
}
0 commit comments