Returns optional or compulsory feature if set, otherwise -1 */
| 166 | |
| 167 | /* Returns optional or compulsory feature if set, otherwise -1 */ |
| 168 | static 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. */ |
| 189 | u32 gossmap_max_node_idx(const struct gossmap *map) |
no test coverage detected