Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/db.h
Show All 32 Lines | private: | ||||
// shutdown problems/crashes caused by a static initialized internal | // shutdown problems/crashes caused by a static initialized internal | ||||
// pointer. | // pointer. | ||||
std::string strPath; | std::string strPath; | ||||
public: | public: | ||||
std::unique_ptr<DbEnv> dbenv; | std::unique_ptr<DbEnv> dbenv; | ||||
std::map<std::string, int> mapFileUseCount; | std::map<std::string, int> mapFileUseCount; | ||||
std::map<std::string, Db *> mapDb; | std::map<std::string, Db *> mapDb; | ||||
std::condition_variable_any m_db_in_use; | |||||
BerkeleyEnvironment(const fs::path &env_directory); | BerkeleyEnvironment(const fs::path &env_directory); | ||||
~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; } | ||||
Show All 25 Lines | bool Salvage(const std::string &strFile, bool fAggressive, | ||||
std::vector<KeyValPair> &vResult); | std::vector<KeyValPair> &vResult); | ||||
bool Open(bool retry); | bool Open(bool retry); | ||||
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(); | |||||
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) return nullptr; | if (!ptxn || ret != 0) return nullptr; | ||||
return ptxn; | return ptxn; | ||||
} | } | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 60 Lines • ▼ Show 20 Lines | public: | ||||
/** | /** | ||||
* Make sure all changes are flushed to disk. | * Make sure all changes are flushed to disk. | ||||
*/ | */ | ||||
void Flush(bool shutdown); | void Flush(bool shutdown); | ||||
void IncrementUpdateCounter(); | void IncrementUpdateCounter(); | ||||
void ReloadDbEnv(); | |||||
std::atomic<unsigned int> nUpdateCounter; | std::atomic<unsigned int> nUpdateCounter; | ||||
unsigned int nLastSeen; | unsigned int nLastSeen; | ||||
unsigned int nLastFlushed; | unsigned int nLastFlushed; | ||||
int64_t nLastWalletUpdate; | int64_t nLastWalletUpdate; | ||||
private: | private: | ||||
/** BerkeleyDB specific */ | /** BerkeleyDB specific */ | ||||
BerkeleyEnvironment *env; | BerkeleyEnvironment *env; | ||||
▲ Show 20 Lines • Show All 253 Lines • Show Last 20 Lines |