features: Add function to unset a featurebit

Needed so we can blank optional bits when comparing channel_types.
This commit is contained in:
Christian Decker 2022-04-15 14:24:09 +02:00
parent 9574c0d89c
commit 49a22a8dd7
2 changed files with 13 additions and 0 deletions

View File

@ -513,6 +513,17 @@ u8 *featurebits_or(const tal_t *ctx, const u8 *f1 TAKES, const u8 *f2 TAKES)
return result;
}
void featurebits_unset(u8 **ptr, size_t bit)
{
size_t len = tal_count(*ptr);
if (bit / 8 >= len)
return;
(*ptr)[len - 1 - bit / 8] &= (0 << (bit % 8));
trim_features(ptr);
}
bool featurebits_eq(const u8 *f1, const u8 *f2)
{
size_t len = tal_bytelen(f1);

View File

@ -73,6 +73,8 @@ void set_feature_bit(u8 **ptr, u32 bit);
/* Given two featurebit vectors, combine them by applying a logical OR. */
u8 *featurebits_or(const tal_t *ctx, const u8 *f1 TAKES, const u8 *f2 TAKES);
/* Unset a given bit in a featurebits string */
void featurebits_unset(u8 **ptr, size_t bit);
/* Are these two feature bitsets functionally equal (one may have
* trailing zeroes)? */