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

Function feature_set_sub

common/features.c:257–284  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

255}
256
257bool feature_set_sub(struct feature_set *a,
258 const struct feature_set *b TAKES)
259{
260 /* Check first, before we change anything! */
261 for (size_t i = 0; i < ARRAY_SIZE(b->bits); i++) {
262 for (size_t j = 0; j < tal_bytelen(b->bits[i])*8; j++) {
263 if (feature_is_set(b->bits[i], j)
264 && !feature_offered(a->bits[i], j)) {
265 if (taken(b))
266 tal_free(b);
267 return false;
268 }
269 }
270 }
271
272 for (size_t i = 0; i < ARRAY_SIZE(a->bits); i++) {
273 for (size_t j = 0; j < tal_bytelen(b->bits[i])*8; j++) {
274 if (feature_is_set(b->bits[i], j))
275 clear_feature_bit(a->bits[i], j);
276 }
277 trim_features(&a->bits[i]);
278 }
279
280
281 if (taken(b))
282 tal_free(b);
283 return true;
284}
285
286/* BOLT #1:
287 *

Callers 2

opt_force_featuresetFunction · 0.85
test_feature_set_subFunction · 0.85

Calls 7

tal_bytelenFunction · 0.85
takenFunction · 0.85
tal_freeFunction · 0.85
clear_feature_bitFunction · 0.85
trim_featuresFunction · 0.85
feature_is_setFunction · 0.70
feature_offeredFunction · 0.70

Tested by 1

test_feature_set_subFunction · 0.68