Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/db.h
Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | public: | ||||
void MakeMock(); | void MakeMock(); | ||||
bool IsMock() const { return fMockDb; } | bool IsMock() const { return fMockDb; } | ||||
bool IsInitialized() const { return fDbEnvInit; } | bool IsInitialized() const { return fDbEnvInit; } | ||||
bool IsDatabaseLoaded(const std::string &db_filename) const { | bool IsDatabaseLoaded(const std::string &db_filename) const { | ||||
return m_databases.find(db_filename) != m_databases.end(); | return m_databases.find(db_filename) != m_databases.end(); | ||||
} | } | ||||
fs::path Directory() const { return strPath; } | fs::path Directory() const { return strPath; } | ||||
/** | bool Verify(const std::string &strFile); | ||||
* Verify that database file strFile is OK. If it is not, call the callback | |||||
* to try to recover. | |||||
* This must be called BEFORE strFile is opened. | |||||
* Returns true if strFile is OK. | |||||
*/ | |||||
enum class VerifyResult { VERIFY_OK, RECOVER_OK, RECOVER_FAIL }; | |||||
typedef bool (*recoverFunc_type)(const fs::path &file_path, | |||||
std::string &out_backup_filename); | |||||
VerifyResult Verify(const std::string &strFile, | |||||
recoverFunc_type recoverFunc, | |||||
std::string &out_backup_filename); | |||||
/** | /** | ||||
* Salvage data from a file that Verify says is bad. | * Salvage data from a file that Verify says is bad. | ||||
* fAggressive sets the DB_AGGRESSIVE flag (see berkeley DB->verify() method | * fAggressive sets the DB_AGGRESSIVE flag (see berkeley DB->verify() method | ||||
* documentation). | * documentation). | ||||
* Appends binary key/value pairs to vResult, returns true if successful. | * Appends binary key/value pairs to vResult, returns true if successful. | ||||
* NOTE: reads the entire database into memory, so cannot be used | * NOTE: reads the entire database into memory, so cannot be used | ||||
* for huge databases. | * for huge databases. | ||||
*/ | */ | ||||
▲ Show 20 Lines • Show All 184 Lines • ▼ Show 20 Lines | public: | ||||
/* flush the wallet passively (TRY_LOCK) | /* flush the wallet passively (TRY_LOCK) | ||||
ideal to be called periodically */ | ideal to be called periodically */ | ||||
static bool PeriodicFlush(BerkeleyDatabase &database); | static bool PeriodicFlush(BerkeleyDatabase &database); | ||||
/* verifies the database environment */ | /* verifies the database environment */ | ||||
static bool VerifyEnvironment(const fs::path &file_path, | static bool VerifyEnvironment(const fs::path &file_path, | ||||
bilingual_str &errorStr); | bilingual_str &errorStr); | ||||
/* verifies the database file */ | /* verifies the database file */ | ||||
static bool | static bool VerifyDatabaseFile(const fs::path &file_path, | ||||
VerifyDatabaseFile(const fs::path &file_path, | bilingual_str &errorStr); | ||||
std::vector<bilingual_str> &warnings, | |||||
bilingual_str &errorStr, | |||||
BerkeleyEnvironment::recoverFunc_type recoverFunc); | |||||
template <typename K, typename T> bool Read(const K &key, T &value) { | template <typename K, typename T> bool Read(const K &key, T &value) { | ||||
if (!pdb) { | if (!pdb) { | ||||
return false; | return false; | ||||
} | } | ||||
// Key | // Key | ||||
CDataStream ssKey(SER_DISK, CLIENT_VERSION); | CDataStream ssKey(SER_DISK, CLIENT_VERSION); | ||||
▲ Show 20 Lines • Show All 155 Lines • Show Last 20 Lines |