aboutsummaryrefslogtreecommitdiff
path: root/src/db.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/db.h')
-rw-r--r--src/db.h30
1 files changed, 26 insertions, 4 deletions
diff --git a/src/db.h b/src/db.h
index 0ff06e40a8..e2983e0787 100644
--- a/src/db.h
+++ b/src/db.h
@@ -25,14 +25,36 @@ class CWallet;
class CWalletTx;
extern unsigned int nWalletDBUpdated;
-extern bool fDetachDB;
-extern DbEnv dbenv;
-extern void DBFlush(bool fShutdown);
void ThreadFlushWalletDB(void* parg);
bool BackupWallet(const CWallet& wallet, const std::string& strDest);
+class CDBEnv
+{
+private:
+ bool fDetachDB;
+ bool fDbEnvInit;
+ boost::filesystem::path pathEnv;
+
+ void EnvShutdown();
+
+public:
+ mutable CCriticalSection cs_db;
+ DbEnv dbenv;
+
+ CDBEnv();
+ ~CDBEnv();
+ bool Open(boost::filesystem::path pathEnv_);
+ void Close();
+ void Flush(bool fShutdown);
+ void CheckpointLSN(std::string strFile);
+ void SetDetach(bool fDetachDB_) { fDetachDB = fDetachDB_; }
+};
+
+extern CDBEnv bitdb;
+
+
/** RAII class that provides access to a Berkeley database */
class CDB
{
@@ -216,7 +238,7 @@ public:
if (!pdb)
return false;
DbTxn* ptxn = NULL;
- int ret = dbenv.txn_begin(GetTxn(), &ptxn, DB_TXN_WRITE_NOSYNC);
+ int ret = bitdb.dbenv.txn_begin(GetTxn(), &ptxn, DB_TXN_WRITE_NOSYNC);
if (!ptxn || ret != 0)
return false;
vTxn.push_back(ptxn);