Skip to content

Commit 37b7399

Browse files
committed
Remove invalid debug_asserts in peer_connected/peer_disconnected
In commit 7d56270, we decided to call `peer_connected`/`peer_disconnected` on the previously-added `send_only_message_handler`. However, in practice `send_only_message_handler` will be implemented via `ChannelManager`, having us call `ChannelManager::peer_connected` at least twice (also for `ChannelMessageHandler`), resulting in hitting the `A peer shouldn't be connected twice` and `Unconnected peer disconnected` debug assertions. Here, we simply drop these outdated assertions.
1 parent d67bd0f commit 37b7399

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

lightning/src/ln/channelmanager.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11917,7 +11917,12 @@ where
1191711917
debug_assert!(peer_state.is_connected, "A disconnected peer cannot disconnect");
1191811918
peer_state.is_connected = false;
1191911919
peer_state.ok_to_remove(true)
11920-
} else { debug_assert!(false, "Unconnected peer disconnected"); true }
11920+
} else {
11921+
// Note that the peer might already be marked as disconnected as we might have
11922+
// called this function already via a different callpath (i.e., other
11923+
// implementation of `BaseMessageHandler`.
11924+
false
11925+
}
1192111926
};
1192211927
if remove_peer {
1192311928
per_peer_state.remove(&counterparty_node_id);
@@ -11981,7 +11986,9 @@ where
1198111986
return NotifyOption::SkipPersistNoEvents;
1198211987
}
1198311988

11984-
debug_assert!(!peer_state.is_connected, "A peer shouldn't be connected twice");
11989+
// Note that the peer might already be marked as connected as we might have
11990+
// called this function already via a different callpath (i.e., other
11991+
// implementation of `BaseMessageHandler`.
1198511992
peer_state.is_connected = true;
1198611993
},
1198711994
}

0 commit comments

Comments
 (0)