diff --git a/src/init.cpp b/src/init.cpp index 9bb44d777..9b9a8f576 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -58,7 +58,7 @@ CWallet* pwalletMain = NULL; int nWalletBackups = 10; #endif bool fFeeEstimatesInitialized = false; -bool wallet_restart = false; // true: restart false: shutdown +bool fRestartRequested = false; // true: restart false: shutdown #ifdef WIN32 // Win32 LevelDB doesn't use filedescriptors, and the ones used for @@ -145,9 +145,9 @@ static CCoinsViewDB *pcoinsdbview = NULL; static CCoinsViewErrorCatcher *pcoinscatcher = NULL; /** Preparing steps before shutting down or restarting the wallet */ -void Prepare_Shutdown() +void PrepareShutdown() { - wallet_restart = true; // Needed when we restart the wallet + fRestartRequested = true; // Needed when we restart the wallet LogPrintf("%s: In progress...\n", __func__); static CCriticalSection cs_Shutdown; TRY_LOCK(cs_Shutdown, lockShutdown); @@ -208,18 +208,18 @@ void Prepare_Shutdown() /** * Shutdown is split into 2 parts: -* Part 1: shut down everything but the main wallet instance (done in Prepare_Shutdown() ) +* Part 1: shut down everything but the main wallet instance (done in PrepareShutdown() ) * Part 2: delete wallet instance * -* In case of a restart Prepare_Shutdown() was already called before, but this method here gets +* In case of a restart PrepareShutdown() was already called before, but this method here gets * called implicitly when the parent object is deleted. In this case we have to skip the -* Prepare_Shutdown() part because it was already executed and just delete the wallet instance. +* PrepareShutdown() part because it was already executed and just delete the wallet instance. */ void Shutdown() { // Shutdown part 1: prepare shutdown - if(!wallet_restart){ - Prepare_Shutdown(); + if(!fRestartRequested){ + PrepareShutdown(); } // Shutdown part 2: delete wallet instance diff --git a/src/init.h b/src/init.h index 93a0fdf39..36300eade 100644 --- a/src/init.h +++ b/src/init.h @@ -20,7 +20,7 @@ extern CWallet* pwalletMain; void StartShutdown(); bool ShutdownRequested(); void Shutdown(); -void Prepare_Shutdown(); +void PrepareShutdown(); bool AppInit2(boost::thread_group& threadGroup); /** The help message mode determines what help message to show */ diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index c1fbc22e6..27d8bba4f 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -357,7 +357,7 @@ void BitcoinGUI::createActions(const NetworkStyle *networkStyle) openNetworkAction->setStatusTip(tr("Show network monitor")); openPeersAction = new QAction(QIcon(":/icons/connect_4"), tr("&Peers list"), this); openPeersAction->setStatusTip(tr("Show peers info")); - openRepairAction = new QAction(QIcon(":/icons/options"), tr("&Repair Wallet"), this); + openRepairAction = new QAction(QIcon(":/icons/options"), tr("Wallet &Repair"), this); openRepairAction->setStatusTip(tr("Repair Wallet Options")); openConfEditorAction = new QAction(QIcon(":/icons/edit"), tr("Open &Configuration File"), this); openConfEditorAction->setStatusTip(tr("Open configuration file")); diff --git a/src/qt/dash.cpp b/src/qt/dash.cpp index 0ef040da3..5a6860ef1 100644 --- a/src/qt/dash.cpp +++ b/src/qt/dash.cpp @@ -282,13 +282,13 @@ void BitcoinCore::initialize() } void BitcoinCore::restart(QStringList args) -{ +{ try { qDebug() << __func__ << ": Running Restart in thread"; threadGroup.interrupt_all(); threadGroup.join_all(); - Prepare_Shutdown(); + PrepareShutdown(); qDebug() << __func__ << ": Shutdown finished"; emit shutdownResult(1); CExplicitNetCleanup::callCleanup(); diff --git a/src/qt/forms/rpcconsole.ui b/src/qt/forms/rpcconsole.ui index 06f7a8fed..55ea018ad 100755 --- a/src/qt/forms/rpcconsole.ui +++ b/src/qt/forms/rpcconsole.ui @@ -1073,7 +1073,7 @@ 10 90 - 180 + 221 23 @@ -1092,7 +1092,7 @@ 10 140 - 180 + 221 23 @@ -1111,7 +1111,7 @@ 10 190 - 180 + 221 23 @@ -1130,7 +1130,7 @@ 10 240 - 180 + 221 23 @@ -1149,7 +1149,7 @@ 10 290 - 180 + 221 23 @@ -1188,9 +1188,9 @@ - 210 + 250 80 - 511 + 471 41 @@ -1204,9 +1204,9 @@ - 210 + 250 129 - 511 + 471 41 @@ -1220,9 +1220,9 @@ - 210 + 250 179 - 511 + 471 41 @@ -1236,9 +1236,9 @@ - 210 + 250 229 - 511 + 471 41 @@ -1252,14 +1252,14 @@ - 210 + 250 279 - 511 + 471 41 - -upgradewallet: Upgrade wallet to latest format on startup. (Note: this is NOT an update of the wallet itself !) + -upgradewallet: Upgrade wallet to latest format on startup. (Note: this is NOT an update of the wallet itself!) true @@ -1293,7 +1293,7 @@ 10 340 - 181 + 221 23 @@ -1304,9 +1304,9 @@ - 210 + 250 330 - 511 + 471 41 diff --git a/src/qt/rpcconsole.cpp b/src/qt/rpcconsole.cpp index 6ce0f162b..1d9fd226d 100644 --- a/src/qt/rpcconsole.cpp +++ b/src/qt/rpcconsole.cpp @@ -42,6 +42,14 @@ const QSize ICON_SIZE(24, 24); const int INITIAL_TRAFFIC_GRAPH_MINS = 30; +// Repair parameters +const QString SALVAGEWALLET("-salvagewallet"); +const QString RESCAN("-rescan"); +const QString ZAPTXES1("-zapwallettxes=1"); +const QString ZAPTXES2("-zapwallettxes=2"); +const QString UPGRADEWALLET("-upgradewallet"); +const QString REINDEX("-reindex"); + const struct { const char *url; const char *source; @@ -222,12 +230,12 @@ RPCConsole::RPCConsole(QWidget *parent) : connect(ui->btnClearTrafficGraph, SIGNAL(clicked()), ui->trafficGraph, SLOT(clear())); // Wallet Repair Buttons - connect(ui->btn_salvagewallet, SIGNAL(clicked()), this, SLOT(wallet_salvage())); - connect(ui->btn_rescan, SIGNAL(clicked()), this, SLOT(wallet_rescan())); - connect(ui->btn_zapwallettxes1, SIGNAL(clicked()), this, SLOT(wallet_zaptxes1())); - connect(ui->btn_zapwallettxes2, SIGNAL(clicked()), this, SLOT(wallet_zaptxes2())); - connect(ui->btn_upgradewallet, SIGNAL(clicked()), this, SLOT(wallet_upgrade())); - connect(ui->btn_reindex, SIGNAL(clicked()), this, SLOT(wallet_reindex())); + connect(ui->btn_salvagewallet, SIGNAL(clicked()), this, SLOT(walletSalvage())); + connect(ui->btn_rescan, SIGNAL(clicked()), this, SLOT(walletRescan())); + connect(ui->btn_zapwallettxes1, SIGNAL(clicked()), this, SLOT(walletZaptxes1())); + connect(ui->btn_zapwallettxes2, SIGNAL(clicked()), this, SLOT(walletZaptxes2())); + connect(ui->btn_upgradewallet, SIGNAL(clicked()), this, SLOT(walletUpgrade())); + connect(ui->btn_reindex, SIGNAL(clicked()), this, SLOT(walletReindex())); // set library version labels ui->openSSLVersion->setText(SSLeay_version(SSLEAY_VERSION)); @@ -345,49 +353,59 @@ static QString categoryClass(int category) } /** Restart wallet with "-salvagewallet" */ -void RPCConsole::wallet_salvage() +void RPCConsole::walletSalvage() { - build_parameter_list(QString("-salvagewallet")); + buildParameterlist(SALVAGEWALLET); } /** Restart wallet with "-rescan" */ -void RPCConsole::wallet_rescan() +void RPCConsole::walletRescan() { - build_parameter_list(QString("-rescan")); + buildParameterlist(RESCAN); } /** Restart wallet with "-zapwallettxes=1" */ -void RPCConsole::wallet_zaptxes1() +void RPCConsole::walletZaptxes1() { - build_parameter_list(QString("-zapwallettxes=1")); + buildParameterlist(ZAPTXES1); } /** Restart wallet with "-zapwallettxes=2" */ -void RPCConsole::wallet_zaptxes2() +void RPCConsole::walletZaptxes2() { - build_parameter_list(QString("-zapwallettxes=2")); + buildParameterlist(ZAPTXES2); } /** Restart wallet with "-upgradewallet" */ -void RPCConsole::wallet_upgrade() +void RPCConsole::walletUpgrade() { - build_parameter_list(QString("-upgradewallet")); + buildParameterlist(UPGRADEWALLET); } /** Restart wallet with "-reindex" */ -void RPCConsole::wallet_reindex() +void RPCConsole::walletReindex() { - build_parameter_list(QString("-reindex")); + buildParameterlist(REINDEX); } /** Build command-line parameter list for restart */ -void RPCConsole::build_parameter_list(QString arg) +void RPCConsole::buildParameterlist(QString arg) { // Get command-line arguments and remove the application name QStringList args = QApplication::arguments(); args.removeFirst(); + + // Remove existing repair-options + args.removeAll(SALVAGEWALLET); + args.removeAll(RESCAN); + args.removeAll(ZAPTXES1); + args.removeAll(ZAPTXES2); + args.removeAll(UPGRADEWALLET); + args.removeAll(REINDEX); + // Append repair parameter to command line. We don't care whether it might already be there args.append(arg); + // Send command-line arguments to BitcoinGUI::handleRestart() emit handleRestart(args); } diff --git a/src/qt/rpcconsole.h b/src/qt/rpcconsole.h index fedde85aa..07281c35a 100644 --- a/src/qt/rpcconsole.h +++ b/src/qt/rpcconsole.h @@ -61,12 +61,12 @@ public slots: void clear(); /** Wallet repair options */ - void wallet_salvage(); - void wallet_rescan(); - void wallet_zaptxes1(); - void wallet_zaptxes2(); - void wallet_upgrade(); - void wallet_reindex(); + void walletSalvage(); + void walletRescan(); + void walletZaptxes1(); + void walletZaptxes2(); + void walletUpgrade(); + void walletReindex(); void reject(); void message(int category, const QString &message, bool html = false); @@ -111,7 +111,7 @@ private: void startExecutor(); void setTrafficGraphRange(int mins); /** Build parameter list for restart */ - void build_parameter_list(QString arg); + void buildParameterlist(QString arg); /** show detailed information on ui about selected node */ void updateNodeDetail(const CNodeCombinedStats *stats);