202 {
203
205 snapshot.seekg(pos);
206 snapshot.exceptions(ex);
207 });
208
209 snapshot.exceptions(std::istream::failbit|std::istream::eofbit);
210
211 try {
212
214 decltype(expected_totem) actual_totem;
215 snapshot.read((char*)&actual_totem, sizeof(actual_totem));
216 SYS_ASSERT(actual_totem == expected_totem, snapshot_exception,
217 "Binary snapshot has unexpected magic number!");
218
219
220 auto expected_version = current_snapshot_version;
221 decltype(expected_version) actual_version;
222 snapshot.read((char*)&actual_version, sizeof(actual_version));
223 SYS_ASSERT(actual_version == expected_version, snapshot_exception,
224 "Binary snapshot is an unsuppored version. Expected : ${expected}, Got: ${actual}",
225 ("expected", expected_version)("actual", actual_version));
226
227 while (validate_section()) {}
228 } catch( const std::exception& e ) { \
229 snapshot_exception fce(
FC_LOG_MESSAGE( warn,
"Binary snapshot validation threw IO exception (${what})",(
"what",e.what())));
230 throw fce;
231 }
232}
#define SYS_ASSERT(expr, exc_type, FORMAT,...)
#define FC_LOG_MESSAGE(LOG_LEVEL, FORMAT,...)
A helper method for generating log messages.