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