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

Function set_feature_bit

common/features.c:276–288  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

274 * All data fields are unsigned big-endian unless otherwise specified.
275 */
276void set_feature_bit(u8 **ptr, u32 bit)
277{
278 size_t len = tal_count(*ptr);
279 if (bit / 8 >= len) {
280 size_t newlen = (bit / 8) + 1;
281 u8 *newarr = tal_arrz(tal_parent(*ptr), u8, newlen);
282 memcpy(newarr + (newlen - len), *ptr, len);
283 tal_free(*ptr);
284 *ptr = newarr;
285 len = newlen;
286 }
287 (*ptr)[len - 1 - bit / 8] |= (1 << (bit % 8));
288}
289
290static bool test_bit(const u8 *features, size_t byte, unsigned int bit)
291{

Callers 15

opt_force_featuresetFunction · 0.85
new_daemonFunction · 0.85
maybe_encode_9Function · 0.85
param_channel_typeFunction · 0.85
feature_set_for_featureFunction · 0.85
feature_set_orFunction · 0.85
test_featurebits_orFunction · 0.85

Calls 2

tal_parentFunction · 0.85
tal_freeFunction · 0.85

Tested by 10

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
json_to_allowed_featuresFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68
mainFunction · 0.68