plugin: Move feature_place enum to features.h

Better not duplicate these, we might end up mixing them.
This commit is contained in:
Christian Decker 2020-03-31 15:32:16 +02:00 committed by Rusty Russell
parent b5b11a3f67
commit 59567dc04b
3 changed files with 15 additions and 8 deletions

View File

@ -19,6 +19,14 @@ struct feature_style {
enum feature_copy_style copy_style[NUM_FEATURE_PLACE];
};
const char *feature_place_names[] = {
"init",
NULL,
"node",
"channel",
"invoice"
};
static const struct feature_style feature_styles[] = {
{ OPT_DATA_LOSS_PROTECT,
.copy_style = { [INIT_FEATURE] = FEATURE_REPRESENT,

View File

@ -13,6 +13,8 @@ enum feature_place {
};
#define NUM_FEATURE_PLACE (BOLT11_FEATURE+1)
extern const char *feature_place_names[NUM_FEATURE_PLACE];
/* The complete set of features for all contexts */
struct feature_set {
u8 *bits[NUM_FEATURE_PLACE];

View File

@ -896,9 +896,6 @@ static void plugin_manifest_timeout(struct plugin *plugin)
fatal("Can't recover from plugin failure, terminating.");
}
/* List of JSON keys matching `enum feature_place`. */
static const char *plugin_feature_place_names[] = {"init", NULL, "node", "channel", "invoice"};
bool plugin_parse_getmanifest_response(const char *buffer,
const jsmntok_t *toks,
const jsmntok_t *idtok,
@ -922,16 +919,16 @@ bool plugin_parse_getmanifest_response(const char *buffer,
bool have_featurebits = false;
struct feature_set *fset = talz(tmpctx, struct feature_set);
BUILD_ASSERT(ARRAY_SIZE(plugin_feature_place_names)
BUILD_ASSERT(ARRAY_SIZE(feature_place_names)
== ARRAY_SIZE(fset->bits));
for (int i = 0; i < ARRAY_SIZE(fset->bits); i++) {
/* We don't allow setting the obs global init */
if (!plugin_feature_place_names[i])
if (!feature_place_names[i])
continue;
tok = json_get_member(buffer, featurestok,
plugin_feature_place_names[i]);
feature_place_names[i]);
if (!tok)
continue;
@ -1214,9 +1211,9 @@ plugin_populate_init_request(struct plugin *plugin, struct jsonrpc_request *req)
json_add_string(req->stream, "network", chainparams->network_name);
json_object_start(req->stream, "feature_set");
for (enum feature_place fp = 0; fp < NUM_FEATURE_PLACE; fp++) {
if (plugin_feature_place_names[fp]) {
if (feature_place_names[fp]) {
json_add_hex_talarr(req->stream,
plugin_feature_place_names[fp],
feature_place_names[fp],
ld->our_features->bits[fp]);
}
}