Browse Source

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>
ppa-0.6.1
Rusty Russell 7 years ago
parent
commit
05ba976a41
  1. 15
      lightningd/channel.c
  2. 22
      lightningd/peer_control.c
  3. 3
      lightningd/peer_control.h

15
lightningd/channel.c

@ -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);
}

22
lightningd/peer_control.c

@ -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. */

3
lightningd/peer_control.h

@ -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,

Loading…
Cancel
Save