mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 20:09:18 +01:00
Add no-reconnect-private option to disable automatic reconnect-attempts
to peers connected to our node with private channels only
This commit is contained in:
parent
abfe55e214
commit
a81c1c51f6
4 changed files with 18 additions and 0 deletions
|
@ -391,6 +391,16 @@ void try_reconnect(const tal_t *ctx,
|
|||
{
|
||||
if (!peer->ld->reconnect)
|
||||
return;
|
||||
if (!peer->ld->reconnect_private) {
|
||||
u32 public_channels = 0;
|
||||
struct channel *channel;
|
||||
list_for_each(&peer->channels, channel, list) {
|
||||
if (channel->channel_flags & CHANNEL_FLAGS_ANNOUNCE_CHANNEL)
|
||||
public_channels++;
|
||||
}
|
||||
if (public_channels == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
/* Did we last attempt to connect recently? Enter backoff mode. */
|
||||
if (time_less(time_between(time_now(), peer->last_connect_attempt),
|
||||
|
|
|
@ -243,6 +243,7 @@ static struct lightningd *new_lightningd(const tal_t *ctx)
|
|||
ld->listen = true;
|
||||
ld->autolisten = true;
|
||||
ld->reconnect = true;
|
||||
ld->reconnect_private = true;
|
||||
ld->try_reexec = false;
|
||||
ld->recover_secret = NULL;
|
||||
ld->db_upgrade_ok = NULL;
|
||||
|
|
|
@ -172,6 +172,9 @@ struct lightningd {
|
|||
/* Do we want to reconnect to other peers? */
|
||||
bool reconnect;
|
||||
|
||||
/* Do we want to reconnect to other peers having only unannouced channels with us? */
|
||||
bool reconnect_private;
|
||||
|
||||
/* How many outstanding startup connection attempts? */
|
||||
size_t num_startup_connects;
|
||||
|
||||
|
|
|
@ -804,6 +804,10 @@ static void dev_register_opts(struct lightningd *ld)
|
|||
opt_set_invbool,
|
||||
&ld->reconnect,
|
||||
"Disable automatic reconnect-attempts by this node, but accept incoming");
|
||||
clnopt_noarg("--dev-no-reconnect-private", OPT_DEV,
|
||||
opt_set_invbool,
|
||||
&ld->reconnect_private,
|
||||
"Disable automatic reconnect-attempts to peers with private channel(s) only, but accept incoming");
|
||||
clnopt_noarg("--dev-fast-reconnect", OPT_DEV,
|
||||
opt_set_bool,
|
||||
&ld->dev_fast_reconnect,
|
||||
|
|
Loading…
Add table
Reference in a new issue