Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/salvage.cpp
Show All 15 Lines | |||||
static const char *DATA_END = "DATA=END"; | static const char *DATA_END = "DATA=END"; | ||||
typedef std::pair<std::vector<uint8_t>, std::vector<uint8_t>> KeyValPair; | typedef std::pair<std::vector<uint8_t>, std::vector<uint8_t>> KeyValPair; | ||||
bool RecoverDatabaseFile(const fs::path &file_path) { | bool RecoverDatabaseFile(const fs::path &file_path) { | ||||
std::string filename; | std::string filename; | ||||
std::shared_ptr<BerkeleyEnvironment> env = | std::shared_ptr<BerkeleyEnvironment> env = | ||||
GetWalletEnv(file_path, filename); | GetWalletEnv(file_path, filename); | ||||
if (!env->Open(true /* retry */)) { | |||||
tfm::format(std::cerr, | |||||
"Error initializing wallet database environment %s!", | |||||
env->Directory()); | |||||
return false; | |||||
} | |||||
// Recovery procedure: | // Recovery procedure: | ||||
// move wallet file to walletfilename.timestamp.bak | // move wallet file to walletfilename.timestamp.bak | ||||
// Call Salvage with fAggressive=true to | // Call Salvage with fAggressive=true to | ||||
// get as much data as possible. | // get as much data as possible. | ||||
// Rewrite salvaged data to fresh wallet file | // Rewrite salvaged data to fresh wallet file | ||||
// Set -rescan so any missing transactions will be | // Set -rescan so any missing transactions will be | ||||
// found. | // found. | ||||
int64_t now = GetTime(); | int64_t now = GetTime(); | ||||
▲ Show 20 Lines • Show All 129 Lines • Show Last 20 Lines |