Browse Source

features: add local_feature_negotiated / global_feature_negotiated helpers.

We currently generally assume the features we offer are fixed; this
makes the code clearer and handles where we offer features iff
EXPERIMENTAL_FEATURES=1

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
plugin-6
Rusty Russell 6 years ago
committed by Christian Decker
parent
commit
be6322a2d3
  1. 15
      common/features.c
  2. 4
      common/features.h

15
common/features.c

@ -133,3 +133,18 @@ bool features_supported(const u8 *globalfeatures, const u8 *localfeatures)
ARRAY_SIZE(our_localfeatures));
}
bool local_feature_negotiated(const u8 *lfeatures, size_t f)
{
if (!feature_offered(lfeatures, f))
return false;
return feature_supported(f, our_localfeatures,
ARRAY_SIZE(our_localfeatures));
}
bool global_feature_negotiated(const u8 *gfeatures, size_t f)
{
if (!feature_offered(gfeatures, f))
return false;
return feature_supported(f, our_globalfeatures,
ARRAY_SIZE(our_globalfeatures));
}

4
common/features.h

@ -14,6 +14,10 @@ u8 *get_offered_localfeatures(const tal_t *ctx);
/* Is this feature bit requested? (Either compulsory or optional) */
bool feature_offered(const u8 *features, size_t f);
/* Was this feature bit offered by them and us? */
bool local_feature_negotiated(const u8 *lfeatures, size_t f);
bool global_feature_negotiated(const u8 *gfeatures, size_t f);
#define COMPULSORY_FEATURE(x) (x)
#define OPTIONAL_FEATURE(x) ((x)+1)

Loading…
Cancel
Save