MCPcopy Create free account
hub / github.com/BTCGPU/BTCGPU / VerifyDatabaseFile

Method VerifyDatabaseFile

src/wallet/db.cpp:343–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

341}
342
343bool BerkeleyBatch::VerifyDatabaseFile(const fs::path& file_path, std::string& warningStr, std::string& errorStr, BerkeleyEnvironment::recoverFunc_type recoverFunc)
344{
345 std::string walletFile;
346 BerkeleyEnvironment* env = GetWalletEnv(file_path, walletFile);
347 fs::path walletDir = env->Directory();
348
349 if (fs::exists(walletDir / walletFile))
350 {
351 std::string backup_filename;
352 BerkeleyEnvironment::VerifyResult r = env->Verify(walletFile, recoverFunc, backup_filename);
353 if (r == BerkeleyEnvironment::VerifyResult::RECOVER_OK)
354 {
355 warningStr = strprintf(_("Warning: Wallet file corrupt, data salvaged!"
356 " Original %s saved as %s in %s; if"
357 " your balance or transactions are incorrect you should"
358 " restore from a backup."),
359 walletFile, backup_filename, walletDir);
360 }
361 if (r == BerkeleyEnvironment::VerifyResult::RECOVER_FAIL)
362 {
363 errorStr = strprintf(_("%s corrupt, salvage failed"), walletFile);
364 return false;
365 }
366 }
367 // also return true if files does not exists
368 return true;
369}
370
371/* End of headers, beginning of key/value data */
372static const char *HEADER_END = "HEADER=END";

Callers

nothing calls this directly

Calls 4

GetWalletEnvFunction · 0.85
_Function · 0.85
DirectoryMethod · 0.80
VerifyMethod · 0.45

Tested by

no test coverage detected