aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/db.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet/db.h')
-rw-r--r--src/wallet/db.h50
1 files changed, 25 insertions, 25 deletions
diff --git a/src/wallet/db.h b/src/wallet/db.h
index 49a9f3f082..5e61280f7a 100644
--- a/src/wallet/db.h
+++ b/src/wallet/db.h
@@ -25,7 +25,7 @@
static const unsigned int DEFAULT_WALLET_DBLOGSIZE = 100;
static const bool DEFAULT_WALLET_PRIVDB = true;
-class CDBEnv
+class BerkeleyEnvironment
{
private:
bool fDbEnvInit;
@@ -39,8 +39,8 @@ public:
std::map<std::string, int> mapFileUseCount;
std::map<std::string, Db*> mapDb;
- CDBEnv(const fs::path& env_directory);
- ~CDBEnv();
+ BerkeleyEnvironment(const fs::path& env_directory);
+ ~BerkeleyEnvironment();
void Reset();
void MakeMock();
@@ -86,23 +86,23 @@ public:
}
};
-/** Get CDBEnv and database filename given a wallet path. */
-CDBEnv* GetWalletEnv(const fs::path& wallet_path, std::string& database_filename);
+/** Get BerkeleyEnvironment and database filename given a wallet path. */
+BerkeleyEnvironment* GetWalletEnv(const fs::path& wallet_path, std::string& database_filename);
/** An instance of this class represents one database.
* For BerkeleyDB this is just a (env, strFile) tuple.
**/
-class CWalletDBWrapper
+class BerkeleyDatabase
{
- friend class CDB;
+ friend class BerkeleyBatch;
public:
/** Create dummy DB handle */
- CWalletDBWrapper() : nUpdateCounter(0), nLastSeen(0), nLastFlushed(0), nLastWalletUpdate(0), env(nullptr)
+ BerkeleyDatabase() : nUpdateCounter(0), nLastSeen(0), nLastFlushed(0), nLastWalletUpdate(0), env(nullptr)
{
}
/** Create DB handle to real database */
- CWalletDBWrapper(const fs::path& wallet_path, bool mock = false) :
+ BerkeleyDatabase(const fs::path& wallet_path, bool mock = false) :
nUpdateCounter(0), nLastSeen(0), nLastFlushed(0), nLastWalletUpdate(0)
{
env = GetWalletEnv(wallet_path, strFile);
@@ -114,21 +114,21 @@ public:
}
/** Return object for accessing database at specified path. */
- static std::unique_ptr<CWalletDBWrapper> Create(const fs::path& path)
+ static std::unique_ptr<BerkeleyDatabase> Create(const fs::path& path)
{
- return MakeUnique<CWalletDBWrapper>(path);
+ return MakeUnique<BerkeleyDatabase>(path);
}
/** Return object for accessing dummy database with no read/write capabilities. */
- static std::unique_ptr<CWalletDBWrapper> CreateDummy()
+ static std::unique_ptr<BerkeleyDatabase> CreateDummy()
{
- return MakeUnique<CWalletDBWrapper>();
+ return MakeUnique<BerkeleyDatabase>();
}
/** Return object for accessing temporary in-memory database. */
- static std::unique_ptr<CWalletDBWrapper> CreateMock()
+ static std::unique_ptr<BerkeleyDatabase> CreateMock()
{
- return MakeUnique<CWalletDBWrapper>("", true /* mock */);
+ return MakeUnique<BerkeleyDatabase>("", true /* mock */);
}
/** Rewrite the entire database on disk, with the exception of key pszSkip if non-zero
@@ -152,7 +152,7 @@ public:
private:
/** BerkeleyDB specific */
- CDBEnv *env;
+ BerkeleyEnvironment *env;
std::string strFile;
/** Return whether this database handle is a dummy for testing.
@@ -164,7 +164,7 @@ private:
/** RAII class that provides access to a Berkeley database */
-class CDB
+class BerkeleyBatch
{
protected:
Db* pdb;
@@ -172,14 +172,14 @@ protected:
DbTxn* activeTxn;
bool fReadOnly;
bool fFlushOnClose;
- CDBEnv *env;
+ BerkeleyEnvironment *env;
public:
- explicit CDB(CWalletDBWrapper& dbw, const char* pszMode = "r+", bool fFlushOnCloseIn=true);
- ~CDB() { Close(); }
+ explicit BerkeleyBatch(BerkeleyDatabase& database, const char* pszMode = "r+", bool fFlushOnCloseIn=true);
+ ~BerkeleyBatch() { Close(); }
- CDB(const CDB&) = delete;
- CDB& operator=(const CDB&) = delete;
+ BerkeleyBatch(const BerkeleyBatch&) = delete;
+ BerkeleyBatch& operator=(const BerkeleyBatch&) = delete;
void Flush();
void Close();
@@ -187,11 +187,11 @@ public:
/* flush the wallet passively (TRY_LOCK)
ideal to be called periodically */
- static bool PeriodicFlush(CWalletDBWrapper& dbw);
+ static bool PeriodicFlush(BerkeleyDatabase& database);
/* verifies the database environment */
static bool VerifyEnvironment(const fs::path& file_path, std::string& errorStr);
/* verifies the database file */
- static bool VerifyDatabaseFile(const fs::path& file_path, std::string& warningStr, std::string& errorStr, CDBEnv::recoverFunc_type recoverFunc);
+ static bool VerifyDatabaseFile(const fs::path& file_path, std::string& warningStr, std::string& errorStr, BerkeleyEnvironment::recoverFunc_type recoverFunc);
public:
template <typename K, typename T>
@@ -387,7 +387,7 @@ public:
return Write(std::string("version"), nVersion);
}
- bool static Rewrite(CWalletDBWrapper& dbw, const char* pszSkip = nullptr);
+ bool static Rewrite(BerkeleyDatabase& database, const char* pszSkip = nullptr);
};
#endif // BITCOIN_WALLET_DB_H