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

Function feature_set_sub

common/features.c:245–270  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

243}
244
245bool feature_set_sub(struct feature_set *a,
246 const struct feature_set *b TAKES)
247{
248 /* Check first, before we change anything! */
249 for (size_t i = 0; i < ARRAY_SIZE(b->bits); i++) {
250 for (size_t j = 0; j < tal_bytelen(b->bits[i])*8; j++) {
251 if (feature_is_set(b->bits[i], j)
252 && !feature_offered(a->bits[i], j)) {
253 tal_free_if_taken(b);
254 return false;
255 }
256 }
257 }
258
259 for (size_t i = 0; i < ARRAY_SIZE(a->bits); i++) {
260 for (size_t j = 0; j < tal_bytelen(b->bits[i])*8; j++) {
261 if (feature_is_set(b->bits[i], j))
262 clear_feature_bit(a->bits[i], j);
263 }
264 trim_features(&a->bits[i]);
265 }
266
267
268 tal_free_if_taken(b);
269 return true;
270}
271
272/* BOLT #1:
273 *

Callers 4

opt_force_featuresetFunction · 0.85
handle_early_optsFunction · 0.85
plugin_config_cbFunction · 0.85
test_feature_set_subFunction · 0.85

Calls 6

tal_bytelenFunction · 0.85
feature_is_setFunction · 0.85
feature_offeredFunction · 0.85
tal_free_if_takenFunction · 0.85
clear_feature_bitFunction · 0.85
trim_featuresFunction · 0.85

Tested by 1

test_feature_set_subFunction · 0.68