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

Function map_feature_test

common/gossmap.c:168–186  ·  view source on GitHub ↗

Returns optional or compulsory feature if set, otherwise -1 */

Source from the content-addressed store, hash-verified

166
167/* Returns optional or compulsory feature if set, otherwise -1 */
168static int map_feature_test(const struct gossmap *map,
169 int compulsory_bit,
170 u64 offset, size_t len)
171{
172 size_t bytenum = compulsory_bit / 8;
173 u8 bits;
174
175 assert(COMPULSORY_FEATURE(compulsory_bit) == compulsory_bit);
176 if (bytenum >= len)
177 return -1;
178
179 /* Note reversed! */
180 bits = map_u8(map, offset + len - 1 - bytenum);
181 if (bits & (1 << (compulsory_bit % 8)))
182 return compulsory_bit;
183 if (bits & (1 << (OPTIONAL_FEATURE(compulsory_bit) % 8)))
184 return OPTIONAL_FEATURE(compulsory_bit);
185 return -1;
186}
187
188/* These values can change across calls to gossmap_check. */
189u32 gossmap_max_node_idx(const struct gossmap *map)

Callers 2

gossmap_chan_get_featureFunction · 0.85
gossmap_node_get_featureFunction · 0.85

Calls 1

map_u8Function · 0.85

Tested by

no test coverage detected