Move log channel_reestablish event when needed
What changed, and why it matters
This commit only changes where and how debug log messages are printed during peer reconnection. It moves a single log line deeper into the code and adds more detailed logging for each type of reconnection message. There is no change to program logic, message handling, or security behavior.
No security action needed. Treat as routine logging cleanup.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch refactors logging in ChannelManager::peer_connected. It removes one blanket log_debug!(‘Generating channel_reestablish events’) and instead emits per-channel, per-message-type debug logs inside the match on ReconnectionMsg variants (Reestablish, OpenChannel V1/V2, None). No control flow, state machine, cryptographic, or network behavior is altered.
Changed components
lightning/src/ln/channelmanager.rsInspect captured patch +30 / −9
diff --git a/lightning/src/ln/channelmanager.rs b/lightning/src/ln/channelmanager.rs
index ada27af..f475a03 100644
--- a/lightning/src/ln/channelmanager.rs
+++ b/lightning/src/ln/channelmanager.rs
@@ -15112,8 +15112,6 @@ impl<
}
}
- log_debug!(logger, "Generating channel_reestablish events");
-
let per_peer_state = self.per_peer_state.read().unwrap();
if let Some(peer_state_mutex) = per_peer_state.get(&counterparty_node_id) {
let mut peer_state_lock = peer_state_mutex.lock().unwrap();
@@ -15131,22 +15129,45 @@ impl<
let logger = WithChannelContext::from(&self.logger, &chan.context(), None);
match chan.peer_connected_get_handshake(self.chain_hash, &&logger) {
ReconnectionMsg::Reestablish(msg) => {
+ log_debug!(
+ logger,
+ "Generated channel_reestablish event for channel {}",
+ chan.context().channel_id()
+ );
pending_msg_events.push(MessageSendEvent::SendChannelReestablish {
node_id: chan.context().get_counterparty_node_id(),
msg,
})
},
- ReconnectionMsg::Open(OpenChannelMessage::V1(msg)) => pending_msg_events
- .push(MessageSendEvent::SendOpenChannel {
+ ReconnectionMsg::Open(OpenChannelMessage::V1(msg)) => {
+ log_debug!(
+ logger,
+ "Generated open_channel event for channel {}",
+ chan.context().channel_id()
+ );
+ pending_msg_events.push(MessageSendEvent::SendOpenChannel {
node_id: chan.context().get_counterparty_node_id(),
msg,
- }),
- ReconnectionMsg::Open(OpenChannelMessage::V2(msg)) => pending_msg_events
- .push(MessageSendEvent::SendOpenChannelV2 {
+ });
+ },
+ ReconnectionMsg::Open(OpenChannelMessage::V2(msg)) => {
+ log_debug!(
+ logger,
+ "Generated open_channel_v2 event for channel {}",
+ chan.context().channel_id()
+ );
+ pending_msg_events.push(MessageSendEvent::SendOpenChannelV2 {
node_id: chan.context().get_counterparty_node_id(),
msg,
- }),
- ReconnectionMsg::None => {},
+ });
+ },
+ ReconnectionMsg::None => {
+ log_debug!(
+ logger,
+ "Peer reconnected. No reconnection message for channel {}",
+ chan.context().channel_id()
+ );
+ },
}
}
}
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.