aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/walletdb.h
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2017-12-08 06:39:22 -0500
committerRussell Yanofsky <russ@yanofsky.org>2018-04-07 11:48:27 -0500
commitea23945dbc6ad239c5acac374d2b54aa12870838 (patch)
treed2ce7e636037accf153bcca2c4b170b91d1e0dd2 /src/wallet/walletdb.h
parentb2e5fe8b559b2f6561ee8f220e9141e401929f5e (diff)
scripted-diff: Rename wallet database classes
-BEGIN VERIFY SCRIPT- sed -i 's/\<CWalletDBWrapper\>/BerkeleyDatabase/g' src/wallet/db.h src/wallet/db.cpp sed -i '/statuses/i/** Backend-agnostic database type. */\nusing WalletDatabase = BerkeleyDatabase\;\n' src/wallet/walletdb.h ren() { git grep -l "\<$1\>" 'src/*.cpp' 'src/*.h' ':(exclude)*dbwrapper*' test | xargs sed -i "s:\<$1\>:$2:g"; } ren CDBEnv BerkeleyEnvironment ren CDB BerkeleyBatch ren CWalletDBWrapper WalletDatabase ren CWalletDB WalletBatch ren dbw database ren m_dbw m_database ren walletdb batch ren pwalletdb batch ren pwalletdbIn batch_in ren wallet/batch.h wallet/walletdb.h ren pwalletdbEncryption encrypted_batch -END VERIFY SCRIPT-
Diffstat (limited to 'src/wallet/walletdb.h')
-rw-r--r--src/wallet/walletdb.h35
1 files changed, 19 insertions, 16 deletions
diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h
index 606b7dace7..23a19ad1c8 100644
--- a/src/wallet/walletdb.h
+++ b/src/wallet/walletdb.h
@@ -20,15 +20,15 @@
/**
* Overview of wallet database classes:
*
- * - CDBEnv is an environment in which the database exists (has no analog in dbwrapper.h)
- * - CWalletDBWrapper represents a wallet database (similar to CDBWrapper in dbwrapper.h)
- * - CDB is a low-level database transaction (similar to CDBBatch in dbwrapper.h)
- * - CWalletDB is a modifier object for the wallet, and encapsulates a database
+ * - BerkeleyEnvironment is an environment in which the database exists (has no analog in dbwrapper.h)
+ * - WalletDatabase represents a wallet database (similar to CDBWrapper in dbwrapper.h)
+ * - BerkeleyBatch is a low-level database transaction (similar to CDBBatch in dbwrapper.h)
+ * - WalletBatch is a modifier object for the wallet, and encapsulates a database
* transaction as well as methods to act on the database (no analog in
* dbwrapper.h)
*
- * The latter two are named confusingly, in contrast to what the names CDB
- * and CWalletDB suggest they are transient transaction objects and don't
+ * The latter two are named confusingly, in contrast to what the names BerkeleyBatch
+ * and WalletBatch suggest they are transient transaction objects and don't
* represent the database itself.
*/
@@ -45,6 +45,9 @@ class CWalletTx;
class uint160;
class uint256;
+/** Backend-agnostic database type. */
+using WalletDatabase = BerkeleyDatabase;
+
/** Error statuses for the wallet database */
enum class DBErrors
{
@@ -138,7 +141,7 @@ public:
* database. It will be committed when the object goes out of scope.
* Optionally (on by default) it will flush to disk as well.
*/
-class CWalletDB
+class WalletBatch
{
private:
template <typename K, typename T>
@@ -147,7 +150,7 @@ private:
if (!batch.Write(key, value, fOverwrite)) {
return false;
}
- m_dbw.IncrementUpdateCounter();
+ m_database.IncrementUpdateCounter();
return true;
}
@@ -157,18 +160,18 @@ private:
if (!batch.Erase(key)) {
return false;
}
- m_dbw.IncrementUpdateCounter();
+ m_database.IncrementUpdateCounter();
return true;
}
public:
- explicit CWalletDB(CWalletDBWrapper& dbw, const char* pszMode = "r+", bool _fFlushOnClose = true) :
- batch(dbw, pszMode, _fFlushOnClose),
- m_dbw(dbw)
+ explicit WalletBatch(WalletDatabase& database, const char* pszMode = "r+", bool _fFlushOnClose = true) :
+ batch(database, pszMode, _fFlushOnClose),
+ m_database(database)
{
}
- CWalletDB(const CWalletDB&) = delete;
- CWalletDB& operator=(const CWalletDB&) = delete;
+ WalletBatch(const WalletBatch&) = delete;
+ WalletBatch& operator=(const WalletBatch&) = delete;
bool WriteName(const std::string& strAddress, const std::string& strName);
bool EraseName(const std::string& strAddress);
@@ -244,8 +247,8 @@ public:
//! Write wallet version
bool WriteVersion(int nVersion);
private:
- CDB batch;
- CWalletDBWrapper& m_dbw;
+ BerkeleyBatch batch;
+ WalletDatabase& m_database;
};
//! Compacts BDB state so that wallet.dat is self-contained (if there are changes)