diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-03-08 11:48:58 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-04-20 17:15:30 +0200 |
commit | 71afe3c0995592ff17968816a833a8ed3ce05bf2 (patch) | |
tree | 84df1ac80d58db77464e500bf152a41bace9a4ac /src/wallet/wallet.h | |
parent | 987a6c09562e1e1e9d6623b999ae9de268490e4b (diff) |
wallet: Introduce database handle wrapper
Abstract database handle from explicit strFilename into
CWalletDBWrapper.
Also move CWallet::Backup to db.cpp - as it deals with representation
details this is a database specific operation.
Diffstat (limited to 'src/wallet/wallet.h')
-rw-r--r-- | src/wallet/wallet.h | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 06e7e14990..318aa2bf97 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -715,17 +715,35 @@ private: */ bool AddWatchOnly(const CScript& dest) override; + std::unique_ptr<CWalletDBWrapper> dbw; + public: /* * Main wallet lock. * This lock protects all the fields added by CWallet * except for: * fFileBacked (immutable after instantiation) - * strWalletFile (immutable after instantiation) */ mutable CCriticalSection cs_wallet; - const std::string strWalletFile; + /** Get database handle used by this wallet. Ideally this function would + * not be necessary. + */ + CWalletDBWrapper& GetDBHandle() + { + return *dbw; + } + + /** Get a name for this wallet for logging/debugging purposes. + */ + std::string GetName() const + { + if (dbw) { + return dbw->GetName(); + } else { + return "dummy"; + } + } void LoadKeyPool(int nIndex, const CKeyPool &keypool) { @@ -752,7 +770,7 @@ public: SetNull(); } - CWallet(const std::string& strWalletFileIn) : strWalletFile(strWalletFileIn) + CWallet(std::unique_ptr<CWalletDBWrapper> dbw_in) : dbw(std::move(dbw_in)) { SetNull(); fFileBacked = true; |