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