Skip to content

Commit d071d95

Browse files
committed
[Java] Don't connect to a peer if they're connected in batteries
1 parent 36c0c41 commit d071d95

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main/java/org/ldk/batteries/NioPeerHandler.java

+4
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ public NioPeerHandler(PeerManager manager) throws IOException {
255255
* @throws IOException If connecting to the remote endpoint fails or internal java.nio errors occur.
256256
*/
257257
public void connect(byte[] their_node_id, java.net.SocketAddress remote, int timeout_ms) throws IOException {
258+
if (this.peer_manager.peer_by_node_id(their_node_id) != null) {
259+
// The peer is already connected, no need to try to reconnect.
260+
return;
261+
}
258262
SocketChannel chan = SocketChannel.open();
259263
boolean connected;
260264
try {

0 commit comments

Comments
 (0)