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

Function map_feature_test

common/gossmap.c:139–157  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

137
138/* Returns optional or compulsory feature if set, otherwise -1 */
139static int map_feature_test(const struct gossmap *map,
140 int compulsory_bit,
141 size_t offset, size_t len)
142{
143 size_t bytenum = compulsory_bit / 8;
144 u8 bits;
145
146 assert(COMPULSORY_FEATURE(compulsory_bit) == compulsory_bit);
147 if (bytenum >= len)
148 return -1;
149
150 /* Note reversed! */
151 bits = map_u8(map, offset + len - 1 - bytenum);
152 if (bits & (1 << (compulsory_bit % 8)))
153 return compulsory_bit;
154 if (bits & (1 << (OPTIONAL_FEATURE(compulsory_bit) % 8)))
155 return OPTIONAL_FEATURE(compulsory_bit);
156 return -1;
157}
158
159/* These values can change across calls to gossmap_check. */
160u32 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