mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
common/features: helper to pretty-print feature bits.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -497,3 +497,18 @@ void towire_feature_set(u8 **pptr, const struct feature_set *fset)
|
|||||||
towire_u8_array(pptr, fset->bits[i], tal_bytelen(fset->bits[i]));
|
towire_u8_array(pptr, fset->bits[i], tal_bytelen(fset->bits[i]));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *fmt_featurebits(const tal_t *ctx, const u8 *featurebits)
|
||||||
|
{
|
||||||
|
size_t size = tal_count(featurebits);
|
||||||
|
char *fmt = tal_strdup(ctx, "");
|
||||||
|
const char *prefix = "";
|
||||||
|
|
||||||
|
for (size_t i = 0; i < size * 8; i++) {
|
||||||
|
if (feature_is_set(featurebits, i)) {
|
||||||
|
tal_append_fmt(&fmt, "%s%zu", prefix, i);
|
||||||
|
prefix = ",";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fmt;
|
||||||
|
}
|
||||||
|
|||||||
@@ -71,6 +71,9 @@ 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);
|
||||||
|
|
||||||
|
/* Good for debugging: returns comma-separated string of bits. */
|
||||||
|
const char *fmt_featurebits(const tal_t *ctx, const u8 *featurebits);
|
||||||
|
|
||||||
/* BOLT #9:
|
/* BOLT #9:
|
||||||
*
|
*
|
||||||
* Flags are numbered from the least-significant bit, at bit 0 (i.e. 0x1,
|
* Flags are numbered from the least-significant bit, at bit 0 (i.e. 0x1,
|
||||||
|
|||||||
Reference in New Issue
Block a user