mirror of
https://github.com/ElementsProject/lightning.git
synced 2024-11-19 09:54:16 +01:00
features: Add function to unset a featurebit
Needed so we can blank optional bits when comparing channel_types.
This commit is contained in:
parent
9574c0d89c
commit
49a22a8dd7
@ -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);
|
||||
|
@ -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)? */
|
||||
|
Loading…
Reference in New Issue
Block a user