connectd: Pass the init_featurebits down to connectd and use in init

The `init_featurebits` are computed at startup, and then cached
indefinitely. They are then used whenever a new `init` handshake is performed.

We could add a new message to push updates to `connectd` whenever a plugin is
added or removed, but that's up for discussion.
This commit is contained in:
Christian Decker
2020-01-30 22:26:57 +01:00
committed by Rusty Russell
parent 58c9a6a004
commit 8d6c8c3cd1
5 changed files with 24 additions and 8 deletions

View File

@@ -337,7 +337,7 @@ static void connect_init_done(struct subd *connectd,
int connectd_init(struct lightningd *ld)
{
int fds[2];
u8 *msg;
u8 *msg, *init_features;
int hsmfd;
struct wireaddr_internal *wireaddrs = ld->proposed_wireaddr;
enum addr_listen_announce *listen_announce = ld->proposed_listen_announce;
@@ -362,6 +362,12 @@ int connectd_init(struct lightningd *ld)
*listen_announce = ADDR_LISTEN_AND_ANNOUNCE;
}
init_features =
featurebits_or(tmpctx,
take(plugins_collect_featurebits(
tmpctx, ld->plugins, PLUGIN_FEATURES_INIT)),
take(get_offered_initfeatures(tmpctx)));
msg = towire_connectctl_init(
tmpctx, chainparams,
&ld->id,
@@ -370,7 +376,7 @@ int connectd_init(struct lightningd *ld)
ld->proxyaddr, ld->use_proxy_always || ld->pure_tor_setup,
IFDEV(ld->dev_allow_localhost, false), ld->config.use_dns,
ld->tor_service_password ? ld->tor_service_password : "",
ld->config.use_v3_autotor);
ld->config.use_v3_autotor, init_features);
subd_req(ld->connectd, ld->connectd, take(msg), -1, 0,
connect_init_done, NULL);