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

Function map_feature_test

common/gossmap.c:165–183  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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