From 7efefd7e2a5f6606d693118da546765e80f53eb6 Mon Sep 17 00:00:00 2001 From: Matt Corallo Date: Tue, 10 Sep 2024 14:26:57 +0000 Subject: [PATCH] Always print why we disconnect explicitly ...and drop the old, confusing, "protocol error" message when we get a duplicate connection from a peer. This should slightly further disambiguate disconnection reasons, which are a key debugging tool for assigning blame. --- lightning/src/ln/peer_handler.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 51695bba09a..80c9c78101e 100644 --- a/lightning/src/ln/peer_handler.rs +++ b/lightning/src/ln/peer_handler.rs @@ -1333,8 +1333,7 @@ impl Ok(res), Err(e) => { - log_trace!(self.logger, "Disconnecting peer due to a protocol error (usually a duplicate connection)."); - self.disconnect_event_internal(peer_descriptor); + self.disconnect_event_internal(peer_descriptor, "of a protocol error"); Err(e) } } @@ -2435,7 +2434,7 @@ impl { let peer = peer_lock.lock().unwrap(); if let Some((node_id, _)) = peer.their_node_id { - log_trace!(WithContext::from(&self.logger, Some(node_id), None, None), "Handling disconnection of peer {}", log_pubkey!(node_id)); + let logger = WithContext::from(&self.logger, Some(node_id), None, None); + log_trace!(logger, "Handling disconnection of peer {} because {}", log_pubkey!(node_id), reason); let removed = self.node_id_to_descriptor.lock().unwrap().remove(&node_id); debug_assert!(removed.is_some(), "descriptor maps should be consistent"); if !peer.handshake_complete() { return; }