Skip to content

Commit 2c15bb4

Browse files
committed
Remove peers from the node_id_to_descriptor even without init
When a peer has finished the noise handshake, but has not yet completed the lightning `Init`-based handshake, they will be present in the `node_id_to_descriptor` set, even though `Peer::handshake_complete()` returns false. Thus, when we go to disconnect such a peer, we must ensure that we remove it from the descriptor set as well. Failing to do so caused an `Inconsistent peers set state!` panic in the C bindings network handler.
1 parent 8311581 commit 2c15bb4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

lightning/src/ln/peer_handler.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -1951,11 +1951,10 @@ impl<Descriptor: SocketDescriptor, CM: Deref, RM: Deref, OM: Deref, L: Deref, CM
19511951
},
19521952
Some(peer_lock) => {
19531953
let peer = peer_lock.lock().unwrap();
1954-
if !peer.handshake_complete() { return; }
1955-
debug_assert!(peer.their_node_id.is_some());
19561954
if let Some((node_id, _)) = peer.their_node_id {
19571955
log_trace!(self.logger, "Handling disconnection of peer {}", log_pubkey!(node_id));
19581956
self.node_id_to_descriptor.lock().unwrap().remove(&node_id);
1957+
if !peer.handshake_complete() { return; }
19591958
self.message_handler.chan_handler.peer_disconnected(&node_id);
19601959
self.message_handler.onion_message_handler.peer_disconnected(&node_id);
19611960
}

0 commit comments

Comments
 (0)