Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/db.cpp
Show First 20 Lines • Show All 417 Lines • ▼ Show 20 Lines | if (!env->Open(true /* retry */)) { | ||||
walletDir); | walletDir); | ||||
return false; | return false; | ||||
} | } | ||||
return true; | return true; | ||||
} | } | ||||
bool BerkeleyBatch::VerifyDatabaseFile( | bool BerkeleyBatch::VerifyDatabaseFile( | ||||
const fs::path &file_path, std::string &warningStr, std::string &errorStr, | const fs::path &file_path, std::vector<std::string> &warnings, | ||||
BerkeleyEnvironment::recoverFunc_type recoverFunc) { | std::string &errorStr, BerkeleyEnvironment::recoverFunc_type recoverFunc) { | ||||
std::string walletFile; | std::string walletFile; | ||||
std::shared_ptr<BerkeleyEnvironment> env = | std::shared_ptr<BerkeleyEnvironment> env = | ||||
GetWalletEnv(file_path, walletFile); | GetWalletEnv(file_path, walletFile); | ||||
fs::path walletDir = env->Directory(); | fs::path walletDir = env->Directory(); | ||||
if (fs::exists(walletDir / walletFile)) { | if (fs::exists(walletDir / walletFile)) { | ||||
std::string backup_filename; | std::string backup_filename; | ||||
BerkeleyEnvironment::VerifyResult r = | BerkeleyEnvironment::VerifyResult r = | ||||
env->Verify(walletFile, recoverFunc, backup_filename); | env->Verify(walletFile, recoverFunc, backup_filename); | ||||
if (r == BerkeleyEnvironment::VerifyResult::RECOVER_OK) { | if (r == BerkeleyEnvironment::VerifyResult::RECOVER_OK) { | ||||
warningStr = strprintf( | warnings.push_back(strprintf( | ||||
_("Warning: Wallet file corrupt, data salvaged! Original %s " | _("Warning: Wallet file corrupt, data salvaged! Original %s " | ||||
"saved as %s in %s; if your balance or transactions are " | "saved as %s in %s; if your balance or transactions are " | ||||
"incorrect you should restore from a backup.") | "incorrect you should restore from a backup.") | ||||
.translated, | .translated, | ||||
walletFile, backup_filename, walletDir); | walletFile, backup_filename, walletDir)); | ||||
} | } | ||||
if (r == BerkeleyEnvironment::VerifyResult::RECOVER_FAIL) { | if (r == BerkeleyEnvironment::VerifyResult::RECOVER_FAIL) { | ||||
errorStr = strprintf(_("%s corrupt, salvage failed").translated, | errorStr = strprintf(_("%s corrupt, salvage failed").translated, | ||||
walletFile); | walletFile); | ||||
return false; | return false; | ||||
} | } | ||||
} | } | ||||
// also return true if files does not exists | // also return true if files does not exists | ||||
▲ Show 20 Lines • Show All 540 Lines • Show Last 20 Lines |