From: Matt Corallo Date: Fri, 2 Nov 2018 14:45:29 +0000 (-0400) Subject: Add logging for (dis)connect in peer_handler/channelmanager X-Git-Tag: v0.0.12~277^2~2 X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=b030e84ad8f9eeb678fa52fa3b589f9e937a46ec;p=rust-lightning Add logging for (dis)connect in peer_handler/channelmanager --- diff --git a/src/ln/channelmanager.rs b/src/ln/channelmanager.rs index ed69e8a03..51bf27045 100644 --- a/src/ln/channelmanager.rs +++ b/src/ln/channelmanager.rs @@ -2703,6 +2703,7 @@ impl ChannelMessageHandler for ChannelManager { let short_to_id = channel_state.short_to_id; let pending_msg_events = channel_state.pending_msg_events; if no_connection_possible { + log_debug!(self, "Failing all channels with {} due to no_connection_possible", log_pubkey!(their_node_id)); channel_state.by_id.retain(|_, chan| { if chan.get_their_node_id() == *their_node_id { if let Some(short_id) = chan.get_short_channel_id() { @@ -2720,6 +2721,7 @@ impl ChannelMessageHandler for ChannelManager { } }); } else { + log_debug!(self, "Marking channels with {} disconnected and generating channel_updates", log_pubkey!(their_node_id)); channel_state.by_id.retain(|_, chan| { if chan.get_their_node_id() == *their_node_id { //TODO: mark channel disabled (and maybe announce such after a timeout). @@ -2750,6 +2752,8 @@ impl ChannelMessageHandler for ChannelManager { } fn peer_connected(&self, their_node_id: &PublicKey) { + log_debug!(self, "Generating channel_reestablish events for {}", log_pubkey!(their_node_id)); + let _ = self.total_consistency_lock.read().unwrap(); let mut channel_state_lock = self.channel_state.lock().unwrap(); let channel_state = channel_state_lock.borrow_parts(); diff --git a/src/ln/peer_handler.rs b/src/ln/peer_handler.rs index d868b0758..5d13df95c 100644 --- a/src/ln/peer_handler.rs +++ b/src/ln/peer_handler.rs @@ -417,10 +417,14 @@ impl PeerManager { () => { match peers.node_id_to_descriptor.entry(peer.their_node_id.unwrap()) { hash_map::Entry::Occupied(_) => { + log_trace!(self, "Got second connection with {}, closing", log_pubkey!(peer.their_node_id.unwrap())); peer.their_node_id = None; // Unset so that we don't generate a peer_disconnected event return Err(PeerHandleError{ no_connection_possible: false }) }, - hash_map::Entry::Vacant(entry) => entry.insert(peer_descriptor.clone()), + hash_map::Entry::Vacant(entry) => { + log_trace!(self, "Finished noise handshake for connection with {}", log_pubkey!(peer.their_node_id.unwrap())); + entry.insert(peer_descriptor.clone()) + }, }; } } @@ -477,6 +481,7 @@ impl PeerManager { log_trace!(self, "Received message of type {} from {}", msg_type, log_pubkey!(peer.their_node_id.unwrap())); if msg_type != 16 && peer.their_global_features.is_none() { // Need an init message as first message + log_trace!(self, "Peer {} sent non-Init first message", log_pubkey!(peer.their_node_id.unwrap())); return Err(PeerHandleError{ no_connection_possible: false }); } let mut reader = ::std::io::Cursor::new(&msg_data[2..]);