MCPcopy Create free account
hub / github.com/ElementsProject/elements / DecodeAsmap

Function DecodeAsmap

src/util/asmap.cpp:194–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

192}
193
194std::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

Callers 1

AppInitMainFunction · 0.85

Calls 6

fopenFunction · 0.85
quotedFunction · 0.85
PathToStringFunction · 0.85
SanityCheckASMapFunction · 0.85
IsNullMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected