mirror of
https://github.com/aljazceru/lightning.git
synced 2026-01-09 09:04:25 +01:00
lightningd: --dev-no-reconnect needs to always suppress reconnection.
It didn't in the restore-from-db case. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -386,17 +386,6 @@ void channel_fail_transient(struct channel *channel, const char *fmt, ...)
|
||||
channel_set_owner(channel, NULL);
|
||||
|
||||
/* Reconnect unless we've dropped/are dropping to chain. */
|
||||
if (channel_active(channel)) {
|
||||
struct lightningd *ld = channel->peer->ld;
|
||||
|
||||
#if DEVELOPER
|
||||
/* Don't schedule an attempt if we disabled reconnections with
|
||||
* the `--dev-no-reconnect` flag */
|
||||
if (ld->no_reconnect)
|
||||
return;
|
||||
#endif /* DEVELOPER */
|
||||
u8 *msg = towire_gossipctl_reach_peer(NULL,
|
||||
&channel->peer->id);
|
||||
subd_send_msg(ld->gossip, take(msg));
|
||||
}
|
||||
if (channel_active(channel))
|
||||
try_reconnect(channel->peer);
|
||||
}
|
||||
|
||||
@@ -1071,6 +1071,22 @@ static const struct json_command close_command = {
|
||||
};
|
||||
AUTODATA(json_command, &close_command);
|
||||
|
||||
void try_reconnect(struct peer *peer)
|
||||
{
|
||||
struct lightningd *ld = peer->ld;
|
||||
u8 *msg;
|
||||
|
||||
#if DEVELOPER
|
||||
/* Don't schedule an attempt if we disabled reconnections with
|
||||
* the `--dev-no-reconnect` flag */
|
||||
if (ld->no_reconnect)
|
||||
return;
|
||||
#endif /* DEVELOPER */
|
||||
|
||||
msg = towire_gossipctl_reach_peer(NULL, &peer->id);
|
||||
subd_send_msg(ld->gossip, take(msg));
|
||||
}
|
||||
|
||||
static void activate_peer(struct peer *peer)
|
||||
{
|
||||
u8 *msg;
|
||||
@@ -1083,10 +1099,8 @@ static void activate_peer(struct peer *peer)
|
||||
|
||||
/* We can only have one active channel: reconnect if not already. */
|
||||
channel = peer_active_channel(peer);
|
||||
if (channel && !channel->owner) {
|
||||
msg = towire_gossipctl_reach_peer(peer, &peer->id);
|
||||
subd_send_msg(peer->ld->gossip, take(msg));
|
||||
}
|
||||
if (channel && !channel->owner)
|
||||
try_reconnect(peer);
|
||||
|
||||
list_for_each(&peer->channels, channel, list) {
|
||||
/* Watching lockin may be unnecessary, but it's harmless. */
|
||||
|
||||
@@ -61,6 +61,9 @@ struct peer *new_peer(struct lightningd *ld, u64 dbid,
|
||||
/* Also removes from db. */
|
||||
void delete_peer(struct peer *peer);
|
||||
|
||||
/* Tell gossipd to try to reconnect (unless --dev-no-reconnect) */
|
||||
void try_reconnect(struct peer *peer);
|
||||
|
||||
struct peer *peer_by_id(struct lightningd *ld, const struct pubkey *id);
|
||||
struct peer *peer_from_json(struct lightningd *ld,
|
||||
const char *buffer,
|
||||
|
||||
Reference in New Issue
Block a user