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

Function feature_set_or

common/features.c:228–255  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

226}
227
228bool feature_set_or(struct feature_set *a,
229 const struct feature_set *b TAKES)
230{
231 /* Check first, before we change anything! */
232 for (size_t i = 0; i < ARRAY_SIZE(b->bits); i++) {
233 /* FIXME: We could allow a plugin to upgrade an optional feature
234 * to a compulsory one? */
235 for (size_t j = 0; j < tal_bytelen(b->bits[i])*8; j++) {
236 if (feature_is_set(b->bits[i], j)
237 && feature_offered(a->bits[i], j)) {
238 if (taken(b))
239 tal_free(b);
240 return false;
241 }
242 }
243 }
244
245 for (size_t i = 0; i < ARRAY_SIZE(a->bits); i++) {
246 for (size_t j = 0; j < tal_bytelen(b->bits[i])*8; j++) {
247 if (feature_is_set(b->bits[i], j))
248 set_feature_bit(&a->bits[i], j);
249 }
250 }
251
252 if (taken(b))
253 tal_free(b);
254 return true;
255}
256
257bool feature_set_sub(struct feature_set *a,
258 const struct feature_set *b TAKES)

Callers 1

test_feature_set_orFunction · 0.50

Calls 6

tal_bytelenFunction · 0.85
takenFunction · 0.85
tal_freeFunction · 0.85
set_feature_bitFunction · 0.85
feature_is_setFunction · 0.70
feature_offeredFunction · 0.70

Tested by 1

test_feature_set_orFunction · 0.40