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

Function feature_set_or

common/features.c:218–243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

216}
217
218bool feature_set_or(struct feature_set *a,
219 const struct feature_set *b TAKES)
220{
221 /* Check first, before we change anything! */
222 for (size_t i = 0; i < ARRAY_SIZE(b->bits); i++) {
223 /* FIXME: We could allow a plugin to upgrade an optional feature
224 * to a compulsory one? */
225 for (size_t j = 0; j < tal_bytelen(b->bits[i])*8; j++) {
226 if (feature_is_set(b->bits[i], j)
227 && feature_offered(a->bits[i], j)) {
228 tal_free_if_taken(b);
229 return false;
230 }
231 }
232 }
233
234 for (size_t i = 0; i < ARRAY_SIZE(a->bits); i++) {
235 for (size_t j = 0; j < tal_bytelen(b->bits[i])*8; j++) {
236 if (feature_is_set(b->bits[i], j))
237 set_feature_bit(&a->bits[i], j);
238 }
239 }
240
241 tal_free_if_taken(b);
242 return true;
243}
244
245bool feature_set_sub(struct feature_set *a,
246 const struct feature_set *b TAKES)

Callers 7

opt_force_featuresetFunction · 0.85
opt_set_dual_fundFunction · 0.85
opt_set_splicingFunction · 0.85
default_featuresFunction · 0.85
test_feature_set_orFunction · 0.85

Calls 5

tal_bytelenFunction · 0.85
feature_is_setFunction · 0.85
feature_offeredFunction · 0.85
tal_free_if_takenFunction · 0.85
set_feature_bitFunction · 0.85

Tested by 1

test_feature_set_orFunction · 0.68