common/features: use bitmaps internally, have explicit init function.

This is to prepare for dynamic features, including making plugins first
class citizens at setting them.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2020-03-31 09:09:00 +10:30
committed by Christian Decker
parent c59327dce1
commit afb76392e4
11 changed files with 180 additions and 76 deletions

View File

@@ -1004,11 +1004,34 @@ void setup_color_and_alias(struct lightningd *ld)
}
}
static void setup_default_features(void)
{
static const u32 default_features[] = {
OPTIONAL_FEATURE(OPT_DATA_LOSS_PROTECT),
OPTIONAL_FEATURE(OPT_UPFRONT_SHUTDOWN_SCRIPT),
OPTIONAL_FEATURE(OPT_GOSSIP_QUERIES),
OPTIONAL_FEATURE(OPT_VAR_ONION),
OPTIONAL_FEATURE(OPT_PAYMENT_SECRET),
OPTIONAL_FEATURE(OPT_BASIC_MPP),
OPTIONAL_FEATURE(OPT_GOSSIP_QUERIES_EX),
OPTIONAL_FEATURE(OPT_STATIC_REMOTEKEY),
};
u8 *f = tal_arr(NULL, u8, 0);
for (size_t i = 0; i < ARRAY_SIZE(default_features); i++)
set_feature_bit(&f, default_features[i]);
features_core_init(take(f));
}
void handle_early_opts(struct lightningd *ld, int argc, char *argv[])
{
/* Make ccan/opt use tal for allocations */
setup_option_allocators();
/* Make sure options are populated. */
setup_default_features();
/*~ List features immediately, before doing anything interesting */
opt_register_early_noarg("--list-features-only",
list_features_and_exit,