MCPcopy Create free account
hub / github.com/ElementsProject/lightning / set_feature_bit

Function set_feature_bit

common/features.c:290–302  ·  view source on GitHub ↗

BOLT #1: * * All data fields are unsigned big-endian unless otherwise specified. */

Source from the content-addressed store, hash-verified

288 * All data fields are unsigned big-endian unless otherwise specified.
289 */
290void set_feature_bit(u8 **ptr, u32 bit)
291{
292 size_t len = tal_count(*ptr);
293 if (bit / 8 >= len) {
294 size_t newlen = (bit / 8) + 1;
295 u8 *newarr = tal_arrz(tal_parent(*ptr), u8, newlen);
296 memcpy(newarr + (newlen - len), *ptr, len);
297 tal_free(*ptr);
298 *ptr = newarr;
299 len = newlen;
300 }
301 (*ptr)[len - 1 - bit / 8] |= (1 << (bit % 8));
302}
303
304static bool test_bit(const u8 *features, size_t byte, unsigned int bit)
305{

Callers 14

opt_force_featuresetFunction · 0.85
maybe_encode_9Function · 0.85
feature_set_for_featureFunction · 0.85
feature_set_orFunction · 0.85
test_featurebits_orFunction · 0.85
test_feature_set_orFunction · 0.85
test_feature_set_subFunction · 0.85
test_feature_trimFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 2

tal_parentFunction · 0.85
tal_freeFunction · 0.85

Tested by 6

test_featurebits_orFunction · 0.68
test_feature_set_orFunction · 0.68
test_feature_set_subFunction · 0.68
test_feature_trimFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68