From 92467073adc11a76a26bbb55ccaed454169636f3 Mon Sep 17 00:00:00 2001 From: Pieter Wuille Date: Sun, 4 Nov 2012 12:48:45 +0100 Subject: [PATCH] Remove -detachdb and stop's detach argument. As the only BDB database left is the wallet, and it is always detached. Also remove IsChainFile() predicate and related chainfile-specific logic. --- src/bitcoinrpc.cpp | 8 +++----- src/db.cpp | 20 +++----------------- src/db.h | 3 --- src/init.cpp | 3 --- src/qt/bitcoinstrings.cpp | 2 -- src/qt/forms/optionsdialog.ui | 10 ---------- src/qt/optionsdialog.cpp | 1 - src/qt/optionsmodel.cpp | 10 ---------- src/qt/optionsmodel.h | 1 - 9 files changed, 6 insertions(+), 52 deletions(-) diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp index 21e37c75..43c8da7a 100644 --- a/src/bitcoinrpc.cpp +++ b/src/bitcoinrpc.cpp @@ -179,14 +179,12 @@ Value help(const Array& params, bool fHelp) Value stop(const Array& params, bool fHelp) { + // Accept the deprecated and ignored 'detach´ boolean argument if (fHelp || params.size() > 1) throw runtime_error( - "stop \n" - " is true or false to detach the database or not for this stop only\n" - "Stop Bitcoin server (and possibly override the detachdb config value)."); + "stop\n" + "Stop Bitcoin server."); // Shutdown will take long enough that the response should get back - if (params.size() > 0) - bitdb.SetDetach(params[0].get_bool()); StartShutdown(); return "Bitcoin server stopping"; } diff --git a/src/db.cpp b/src/db.cpp index cf96fe6e..fb405fc2 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -271,14 +271,6 @@ CDB::CDB(const char *pszFile, const char* pszMode) : } } -static bool IsChainFile(std::string strFile) -{ - if (strFile == "coins.dat" || strFile == "blktree.dat") - return true; - - return false; -} - void CDB::Flush() { if (activeTxn) @@ -288,10 +280,6 @@ void CDB::Flush() unsigned int nMinutes = 0; if (fReadOnly) nMinutes = 1; - if (IsChainFile(strFile)) - nMinutes = 2; - if (IsChainFile(strFile) && IsInitialBlockDownload()) - nMinutes = 5; bitdb.dbenv.txn_checkpoint(nMinutes ? GetArg("-dblogsize", 100)*1024 : 0, nMinutes, 0); } @@ -453,11 +441,9 @@ void CDBEnv::Flush(bool fShutdown) CloseDb(strFile); printf("%s checkpoint\n", strFile.c_str()); dbenv.txn_checkpoint(0, 0, 0); - if (!IsChainFile(strFile) || fDetachDB) { - printf("%s detach\n", strFile.c_str()); - if (!fMockDb) - dbenv.lsn_reset(strFile.c_str(), 0); - } + printf("%s detach\n", strFile.c_str()); + if (!fMockDb) + dbenv.lsn_reset(strFile.c_str(), 0); printf("%s closed\n", strFile.c_str()); mapFileUseCount.erase(mi++); } diff --git a/src/db.h b/src/db.h index 9a5f1ca9..9cfbf4fd 100644 --- a/src/db.h +++ b/src/db.h @@ -31,7 +31,6 @@ bool BackupWallet(const CWallet& wallet, const std::string& strDest); class CDBEnv { private: - bool fDetachDB; bool fDbEnvInit; bool fMockDb; boost::filesystem::path pathEnv; @@ -71,8 +70,6 @@ public: void Close(); void Flush(bool fShutdown); void CheckpointLSN(std::string strFile); - void SetDetach(bool fDetachDB_) { fDetachDB = fDetachDB_; } - bool GetDetach() { return fDetachDB; } void CloseDb(const std::string& strFile); bool RemoveDb(const std::string& strFile); diff --git a/src/init.cpp b/src/init.cpp index 1724382b..b096262d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -265,7 +265,6 @@ std::string HelpMessage() " -upnp " + _("Use UPnP to map the listening port (default: 0)") + "\n" + #endif #endif - " -detachdb " + _("Detach block and address databases. Increases shutdown time (default: 0)") + "\n" + " -paytxfee= " + _("Fee per KB to add to transactions you send") + "\n" + #ifdef QT_GUI " -server " + _("Accept command line and JSON-RPC commands") + "\n" + @@ -408,8 +407,6 @@ bool AppInit2() else fDebugNet = GetBoolArg("-debugnet"); - bitdb.SetDetach(GetBoolArg("-detachdb", false)); - #if !defined(WIN32) && !defined(QT_GUI) fDaemon = GetBoolArg("-daemon"); #else diff --git a/src/qt/bitcoinstrings.cpp b/src/qt/bitcoinstrings.cpp index b92a26c4..7e8e102e 100644 --- a/src/qt/bitcoinstrings.cpp +++ b/src/qt/bitcoinstrings.cpp @@ -27,8 +27,6 @@ QT_TRANSLATE_NOOP("bitcoin-core", "" "Cannot obtain a lock on data directory %s. Bitcoin is probably already " "running."), QT_TRANSLATE_NOOP("bitcoin-core", "" -"Detach block and address databases. Increases shutdown time (default: 0)"), -QT_TRANSLATE_NOOP("bitcoin-core", "" "Error: The transaction was rejected. This might happen if some of the coins " "in your wallet were already spent, such as if you used a copy of wallet.dat " "and coins were spent in the copy but not marked as spent here."), diff --git a/src/qt/forms/optionsdialog.ui b/src/qt/forms/optionsdialog.ui index 1b81b0cd..6a133619 100644 --- a/src/qt/forms/optionsdialog.ui +++ b/src/qt/forms/optionsdialog.ui @@ -86,16 +86,6 @@ - - - - Detach block and address databases at shutdown. This means they can be moved to another data directory, but it slows down shutdown. The wallet is always detached. - - - &Detach databases at shutdown - - - diff --git a/src/qt/optionsdialog.cpp b/src/qt/optionsdialog.cpp index 3fb30a95..03dcb0b5 100644 --- a/src/qt/optionsdialog.cpp +++ b/src/qt/optionsdialog.cpp @@ -128,7 +128,6 @@ void OptionsDialog::setMapper() /* Main */ mapper->addMapping(ui->transactionFee, OptionsModel::Fee); mapper->addMapping(ui->bitcoinAtStartup, OptionsModel::StartAtStartup); - mapper->addMapping(ui->detachDatabases, OptionsModel::DetachDatabases); /* Network */ mapper->addMapping(ui->mapPortUpnp, OptionsModel::MapPortUPnP); diff --git a/src/qt/optionsmodel.cpp b/src/qt/optionsmodel.cpp index 1075ce1e..e3c9413f 100644 --- a/src/qt/optionsmodel.cpp +++ b/src/qt/optionsmodel.cpp @@ -56,8 +56,6 @@ void OptionsModel::Init() SoftSetArg("-proxy", settings.value("addrProxy").toString().toStdString()); if (settings.contains("nSocksVersion") && settings.value("fUseProxy").toBool()) SoftSetArg("-socks", settings.value("nSocksVersion").toString().toStdString()); - if (settings.contains("detachDB")) - SoftSetBoolArg("-detachdb", settings.value("detachDB").toBool()); if (!language.isEmpty()) SoftSetArg("-lang", language.toStdString()); } @@ -173,8 +171,6 @@ QVariant OptionsModel::data(const QModelIndex & index, int role) const return QVariant(nDisplayUnit); case DisplayAddresses: return QVariant(bDisplayAddresses); - case DetachDatabases: - return QVariant(bitdb.GetDetach()); case Language: return settings.value("language", ""); default: @@ -256,12 +252,6 @@ bool OptionsModel::setData(const QModelIndex & index, const QVariant & value, in bDisplayAddresses = value.toBool(); settings.setValue("bDisplayAddresses", bDisplayAddresses); break; - case DetachDatabases: { - bool fDetachDB = value.toBool(); - bitdb.SetDetach(fDetachDB); - settings.setValue("detachDB", fDetachDB); - } - break; case Language: settings.setValue("language", value); break; diff --git a/src/qt/optionsmodel.h b/src/qt/optionsmodel.h index 2d86a7a9..4f893bb4 100644 --- a/src/qt/optionsmodel.h +++ b/src/qt/optionsmodel.h @@ -28,7 +28,6 @@ public: Fee, // qint64 DisplayUnit, // BitcoinUnits::Unit DisplayAddresses, // bool - DetachDatabases, // bool Language, // QString OptionIDRowCount, };