static map<string, int> mapFileUseCount;
static map<string, Db*> mapDb;
-static void EnvShutdown(bool fRemoveLogFiles)
+static bool fRemoveLogFiles = false;
+void RemoveLogFilesOnShutdown(bool fIn)
+{
+ fRemoveLogFiles = fIn;
+}
+static void EnvShutdown()
{
if (!fDbEnvInit)
return;
}
~CDBInit()
{
- EnvShutdown(false);
+ EnvShutdown();
}
}
instance_of_cdbinit;
}
-void DBFlush(bool fShutdown, bool fRemoveLogFiles)
+void DBFlush(bool fShutdown)
{
// Flush log data to the actual data file
// on all files that are not in use
if (mapFileUseCount.empty())
{
dbenv.log_archive(&listp, DB_ARCH_REMOVE);
- EnvShutdown(fRemoveLogFiles);
+ EnvShutdown();
}
}
}
extern DbEnv dbenv;
-extern void DBFlush(bool fShutdown, bool fRemoveLogFiles);
+extern void RemoveLogFilesOnShutdown(bool fRemoveLogFiles);
+extern void DBFlush(bool fShutdown);
void ThreadFlushWalletDB(void* parg);
bool BackupWallet(const CWallet& wallet, const std::string& strDest);
{
fShutdown = true;
nTransactionsUpdated++;
- DBFlush(false, false);
+ DBFlush(false);
StopNode();
- DBFlush(true, true);
+ DBFlush(true);
boost::filesystem::remove(GetPidFile());
UnregisterWallet(pwalletMain);
delete pwalletMain;
// Need to completely rewrite the wallet file; if we don't, bdb might keep
// bits of the unencrypted private key in slack space in the database file.
- setKeyPool.clear();
- CDB::Rewrite(strWalletFile);
+ if (CDB::Rewrite(strWalletFile))
+ RemoveLogFilesOnShutdown(true);
}
return true;
{
if (CDB::Rewrite(strWalletFile, "\x04pool"))
{
+ RemoveLogFilesOnShutdown(true);
setKeyPool.clear();
// Note: can't top-up keypool here, because wallet is locked.
// User will be prompted to unlock wallet the next operation