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.
This commit is contained in:
Wladimir J. van der Laan
2017-03-08 12:08:26 +00:00
parent 71afe3c099
commit 071c95570b
4 changed files with 52 additions and 81 deletions

View File

@@ -364,7 +364,10 @@ CDB::CDB(CWalletDBWrapper& dbw, const char* pszMode, bool fFlushOnCloseIn) : pdb
int ret;
fReadOnly = (!strchr(pszMode, '+') && !strchr(pszMode, 'w'));
fFlushOnClose = fFlushOnCloseIn;
const std::string& strFilename = dbw.strFile;
if (dbw.IsDummy()) {
return;
}
const std::string &strFilename = dbw.strFile;
bool fCreate = strchr(pszMode, 'c') != NULL;
unsigned int nFlags = DB_THREAD;
@@ -473,7 +476,7 @@ bool CDBEnv::RemoveDb(const std::string& strFile)
bool CDB::Rewrite(CWalletDBWrapper& dbw, const char* pszSkip)
{
if (!dbw.env) {
if (dbw.IsDummy()) {
return true;
}
const std::string& strFile = dbw.strFile;
@@ -601,6 +604,9 @@ void CDBEnv::Flush(bool fShutdown)
bool CDB::PeriodicFlush(CWalletDBWrapper& dbw)
{
if (dbw.IsDummy()) {
return true;
}
bool ret = false;
const std::string& strFile = dbw.strFile;
TRY_LOCK(bitdb.cs_db,lockDb);
@@ -645,7 +651,7 @@ bool CWalletDBWrapper::Rewrite(const char* pszSkip)
bool CWalletDBWrapper::Backup(const std::string& strDest)
{
if (!env) {
if (IsDummy()) {
return false;
}
while (true)