Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions lightningd/connect_control.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,21 +219,28 @@ static struct command_result *json_connect(struct command *cmd,

/* If we know about peer, see if it's already connected. */
peer = peer_by_id(cmd->ld, &id_addr.id);
if (peer && peer->connected == PEER_CONNECTED) {
log_debug(cmd->ld->log, "Already connected via %s",
fmt_wireaddr_internal(tmpctx,
if (peer) {
switch (peer->connected) {
case PEER_CONNECTED:
log_debug(cmd->ld->log, "Already connected via %s",
fmt_wireaddr_internal(tmpctx,
&peer->addr));
return connect_cmd_succeed(cmd, peer,
peer->connected_incoming,
&peer->addr);
return connect_cmd_succeed(cmd, peer,
peer->connected_incoming,
&peer->addr);
case PEER_DISCONNECTED:
/* When a peer disconnects, we give subds time to clean themselves up
* (this lets connectd ensure they've seen the final messages). But
* now it's going to try to reconnect, we've gotta force them out. */
peer_channels_cleanup(peer);
break;
case PEER_CONNECTING:
/* Just wait until connection finished. Though we still ask connectd to connect,
* it's going to ignore it. */
break;
}
}

/* When a peer disconnects, we give subds time to clean themselves up
* (this lets connectd ensure they've seen the final messages). But
* now it's going to try to reconnect, we've gotta force them out. */
if (peer)
peer_channels_cleanup(peer);

subd_send_msg(cmd->ld->connectd,
take(towire_connectd_connect_to_peer(NULL, &id_addr.id,
addr, true,
Expand Down
Loading