aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/walletdb.h
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-06-12 13:02:37 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2017-06-12 13:27:17 +0200
commit177433ad22d6b386fec10a92a14cd8472ea02f41 (patch)
tree6f040ac85dd5f67b6d9c3bf326fe85efcf74c170 /src/wallet/walletdb.h
parentfa1f106218b9931ae31074f8639d8da1b1ac92a9 (diff)
parentc237bd750e11472f0f9639891036b975cf7faf15 (diff)
downloadbitcoin-177433ad22d6b386fec10a92a14cd8472ea02f41.tar.xz
Merge #8694: Basic multiwallet support
c237bd7 wallet: Update formatting (Luke Dashjr) 9cbe8c8 wallet: Forbid -salvagewallet, -zapwallettxes, and -upgradewallet with multiple wallets (Luke Dashjr) a2a5f3f wallet: Base backup filenames on original wallet filename (Luke Dashjr) b823a4c wallet: Include actual backup filename in recovery warning message (Luke Dashjr) 84dcb45 Bugfix: wallet: Fix warningStr, errorStr argument order (Luke Dashjr) 008c360 Wallet: Move multiwallet sanity checks to CWallet::Verify, and do other checks on all wallets (Luke Dashjr) 0f08575 Wallet: Support loading multiple wallets if -wallet used more than once (Luke Dashjr) b124cf0 Wallet: Replace pwalletMain with a vector of wallet pointers (Luke Dashjr) 19b3648 CWalletDB: Store the update counter per wallet (Luke Dashjr) 74e8738 Bugfix: ForceSetArg should replace entr(ies) in mapMultiArgs, not append (Luke Dashjr) 23fb9ad wallet: Move nAccountingEntryNumber from static/global to CWallet (Luke Dashjr) 9d15d55 Bugfix: wallet: Increment "update counter" when modifying account stuff (Luke Dashjr) f28eb80 Bugfix: wallet: Increment "update counter" only after actually making the applicable db changes to avoid potential races (Luke Dashjr) Tree-SHA512: 23f5dda58477307bc07997010740f1dc729164cdddefd2f9a2c9c7a877111eb1516d3e2ad4f9b104621f0b7f17369c69fcef13d28b85cb6c01d35f09a8845f23
Diffstat (limited to 'src/wallet/walletdb.h')
-rw-r--r--src/wallet/walletdb.h33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/wallet/walletdb.h b/src/wallet/walletdb.h
index cd9fe279c5..d78f143ebd 100644
--- a/src/wallet/walletdb.h
+++ b/src/wallet/walletdb.h
@@ -140,9 +140,31 @@ public:
*/
class CWalletDB
{
+private:
+ template <typename K, typename T>
+ bool WriteIC(const K& key, const T& value, bool fOverwrite = true)
+ {
+ if (!batch.Write(key, value, fOverwrite)) {
+ return false;
+ }
+ m_dbw.IncrementUpdateCounter();
+ return true;
+ }
+
+ template <typename K>
+ bool EraseIC(const K& key)
+ {
+ if (!batch.Erase(key)) {
+ return false;
+ }
+ m_dbw.IncrementUpdateCounter();
+ return true;
+ }
+
public:
CWalletDB(CWalletDBWrapper& dbw, const char* pszMode = "r+", bool _fFlushOnClose = true) :
- batch(dbw, pszMode, _fFlushOnClose)
+ batch(dbw, pszMode, _fFlushOnClose),
+ m_dbw(dbw)
{
}
@@ -180,7 +202,6 @@ public:
/// This writes directly to the database, and will not update the CWallet's cached accounting entries!
/// Use wallet.AddAccountingEntry instead, to write *and* update its caches.
bool WriteAccountingEntry(const uint64_t nAccEntryNum, const CAccountingEntry& acentry);
- bool WriteAccountingEntry_Backend(const CAccountingEntry& acentry);
bool ReadAccount(const std::string& strAccount, CAccount& account);
bool WriteAccount(const std::string& strAccount, const CAccount& account);
@@ -197,9 +218,9 @@ public:
DBErrors ZapWalletTx(std::vector<CWalletTx>& vWtx);
DBErrors ZapSelectTx(std::vector<uint256>& vHashIn, std::vector<uint256>& vHashOut);
/* Try to (very carefully!) recover wallet database (with a possible key type filter) */
- static bool Recover(const std::string& filename, void *callbackDataIn, bool (*recoverKVcallback)(void* callbackData, CDataStream ssKey, CDataStream ssValue));
+ static bool Recover(const std::string& filename, void *callbackDataIn, bool (*recoverKVcallback)(void* callbackData, CDataStream ssKey, CDataStream ssValue), std::string& out_backup_filename);
/* Recover convenience-function to bypass the key filter callback, called when verify fails, recovers everything */
- static bool Recover(const std::string& filename);
+ static bool Recover(const std::string& filename, std::string& out_backup_filename);
/* Recover filter (used as callback), will only let keys (cryptographical keys) as KV/key-type pass through */
static bool RecoverKeysOnlyFilter(void *callbackData, CDataStream ssKey, CDataStream ssValue);
/* Function to determine if a certain KV/key-type is a key (cryptographical key) type */
@@ -212,9 +233,6 @@ public:
//! write the hdchain model (external chain child index counter)
bool WriteHDChain(const CHDChain& chain);
- static void IncrementUpdateCounter();
- static unsigned int GetUpdateCounter();
-
//! Begin a new transaction
bool TxnBegin();
//! Commit current transaction
@@ -227,6 +245,7 @@ public:
bool WriteVersion(int nVersion);
private:
CDB batch;
+ CWalletDBWrapper& m_dbw;
CWalletDB(const CWalletDB&);
void operator=(const CWalletDB&);