diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-03-08 12:08:26 +0000 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-04-20 17:15:31 +0200 |
commit | 071c95570b8e2ee5c2a4aed8b86b9b14f8e75578 (patch) | |
tree | 221b1970c08d70f77b433ca0fc1b3a6457c79f49 /src/wallet/db.h | |
parent | 71afe3c0995592ff17968816a833a8ed3ce05bf2 (diff) |
wallet: Get rid of fFileBacked
Instead, CWalletDB() with a dummy handle will just give you a no-op
database in which writes always succeeds and reads always fail. CDB
already had functionality for this, so just use that.
Diffstat (limited to 'src/wallet/db.h')
-rw-r--r-- | src/wallet/db.h | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/src/wallet/db.h b/src/wallet/db.h index f6d0d54114..892c8d33c3 100644 --- a/src/wallet/db.h +++ b/src/wallet/db.h @@ -93,6 +93,12 @@ class CWalletDBWrapper { friend class CDB; public: + /** Create dummy DB handle */ + CWalletDBWrapper(): env(nullptr) + { + } + + /** Create DB handle to real database */ CWalletDBWrapper(CDBEnv *env_in, const std::string &strFile_in): env(env_in), strFile(strFile_in) { @@ -110,6 +116,12 @@ public: */ std::string GetName() const { return strFile; } + /** Return whether this database handle is a dummy for testing. + * Only to be used at a low level, application should ideally not care + * about this. + */ + bool IsDummy() { return env == nullptr; } + private: /** BerkeleyDB specific */ CDBEnv *env; @@ -186,7 +198,7 @@ protected: bool Write(const K& key, const T& value, bool fOverwrite = true) { if (!pdb) - return false; + return true; if (fReadOnly) assert(!"Write called on database in read-only mode"); |