mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-03-15 11:59:16 +01:00
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>
This commit is contained in:
parent
fab5027d64
commit
be6322a2d3
2 changed files with 19 additions and 0 deletions
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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…
Add table
Reference in a new issue