mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +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:
@@ -516,6 +516,17 @@ u8 *featurebits_or(const tal_t *ctx, const u8 *f1 TAKES, const u8 *f2 TAKES)
|
|||||||
return result;
|
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)
|
bool featurebits_eq(const u8 *f1, const u8 *f2)
|
||||||
{
|
{
|
||||||
size_t len = tal_bytelen(f1);
|
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. */
|
/* 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);
|
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
|
/* Are these two feature bitsets functionally equal (one may have
|
||||||
* trailing zeroes)? */
|
* trailing zeroes)? */
|
||||||
|
|||||||
Reference in New Issue
Block a user