Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/bdb.h
Show First 20 Lines • Show All 51 Lines • ▼ Show 20 Lines | public: | ||||
BerkeleyEnvironment(const fs::path &env_directory); | BerkeleyEnvironment(const fs::path &env_directory); | ||||
BerkeleyEnvironment(); | BerkeleyEnvironment(); | ||||
~BerkeleyEnvironment(); | ~BerkeleyEnvironment(); | ||||
void Reset(); | void Reset(); | ||||
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 { | |||||
return m_databases.find(db_filename) != m_databases.end(); | |||||
} | |||||
fs::path Directory() const { return strPath; } | fs::path Directory() const { return strPath; } | ||||
bool Open(bilingual_str &error); | bool Open(bilingual_str &error); | ||||
void Close(); | void Close(); | ||||
void Flush(bool fShutdown); | void Flush(bool fShutdown); | ||||
void CheckpointLSN(const std::string &strFile); | void CheckpointLSN(const std::string &strFile); | ||||
void CloseDb(const std::string &strFile); | void CloseDb(const std::string &strFile); | ||||
void ReloadDbEnv(); | void ReloadDbEnv(); | ||||
DbTxn *TxnBegin(int flags = DB_TXN_WRITE_NOSYNC) { | DbTxn *TxnBegin(int flags = DB_TXN_WRITE_NOSYNC) { | ||||
DbTxn *ptxn = nullptr; | DbTxn *ptxn = nullptr; | ||||
int ret = dbenv->txn_begin(nullptr, &ptxn, flags); | int ret = dbenv->txn_begin(nullptr, &ptxn, flags); | ||||
if (!ptxn || ret != 0) { | if (!ptxn || ret != 0) { | ||||
return nullptr; | return nullptr; | ||||
} | } | ||||
return ptxn; | return ptxn; | ||||
} | } | ||||
}; | }; | ||||
/** Get BerkeleyEnvironment and database filename given a wallet path. */ | /** Get BerkeleyEnvironment and database filename given a wallet path. */ | ||||
std::shared_ptr<BerkeleyEnvironment> | std::shared_ptr<BerkeleyEnvironment> | ||||
GetWalletEnv(const fs::path &wallet_path, std::string &database_filename); | GetWalletEnv(const fs::path &wallet_path, std::string &database_filename); | ||||
/** Return whether a BDB wallet database is currently loaded. */ | |||||
bool IsBDBWalletLoaded(const fs::path &wallet_path); | |||||
/** Check format of database file */ | /** Check format of database file */ | ||||
bool IsBerkeleyBtree(const fs::path &path); | bool IsBerkeleyBtree(const fs::path &path); | ||||
class BerkeleyBatch; | class BerkeleyBatch; | ||||
/** | /** | ||||
* An instance of this class represents one database. | * An instance of this class represents one database. | ||||
* For BerkeleyDB this is just a (env, strFile) tuple. | * For BerkeleyDB this is just a (env, strFile) tuple. | ||||
▲ Show 20 Lines • Show All 58 Lines • ▼ Show 20 Lines | public: | ||||
*/ | */ | ||||
bool PeriodicFlush() override; | bool PeriodicFlush() override; | ||||
void IncrementUpdateCounter() override; | void IncrementUpdateCounter() override; | ||||
void ReloadDbEnv() override; | void ReloadDbEnv() override; | ||||
/** Verifies the environment and database file */ | /** Verifies the environment and database file */ | ||||
bool Verify(bilingual_str &error) override; | bool Verify(bilingual_str &error); | ||||
/** | /** | ||||
* Pointer to shared database environment. | * Pointer to shared database environment. | ||||
* | * | ||||
* Normally there is only one BerkeleyDatabase object per | * Normally there is only one BerkeleyDatabase object per | ||||
* BerkeleyEnvivonment, but in the special, backwards compatible case where | * BerkeleyEnvivonment, but in the special, backwards compatible case where | ||||
* multiple wallet BDB data files are loaded from the same directory, this | * multiple wallet BDB data files are loaded from the same directory, this | ||||
* will point to a shared instance that gets freed when the last data file | * will point to a shared instance that gets freed when the last data file | ||||
▲ Show 20 Lines • Show All 87 Lines • Show Last 20 Lines |