| 192 | } |
| 193 | |
| 194 | std::vector<bool> DecodeAsmap(fs::path path) |
| 195 | { |
| 196 | std::vector<bool> bits; |
| 197 | FILE *filestr = fsbridge::fopen(path, "rb"); |
| 198 | CAutoFile file(filestr, SER_DISK, CLIENT_VERSION); |
| 199 | if (file.IsNull()) { |
| 200 | LogPrintf("Failed to open asmap file from disk\n"); |
| 201 | return bits; |
| 202 | } |
| 203 | fseek(filestr, 0, SEEK_END); |
| 204 | int length = ftell(filestr); |
| 205 | LogPrintf("Opened asmap file %s (%d bytes) from disk\n", fs::quoted(fs::PathToString(path)), length); |
| 206 | fseek(filestr, 0, SEEK_SET); |
| 207 | uint8_t cur_byte; |
| 208 | for (int i = 0; i < length; ++i) { |
| 209 | file >> cur_byte; |
| 210 | for (int bit = 0; bit < 8; ++bit) { |
| 211 | bits.push_back((cur_byte >> bit) & 1); |
| 212 | } |
| 213 | } |
| 214 | if (!SanityCheckASMap(bits, 128)) { |
| 215 | LogPrintf("Sanity check of asmap file %s failed\n", fs::quoted(fs::PathToString(path))); |
| 216 | return {}; |
| 217 | } |
| 218 | return bits; |
| 219 | } |
| 220 |
no test coverage detected