From: Matt Corallo Date: Tue, 10 Sep 2024 14:26:57 +0000 (+0000) Subject: Always print why we disconnect explicitly X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=refs%2Fheads%2F2024-09-always-print-why;p=rust-lightning 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. --- diff --git a/lightning/src/ln/peer_handler.rs b/lightning/src/ln/peer_handler.rs index 51695bba0..80c9c7810 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; }