Wallet Repair Buttons: refactoring and remove old repair args before restart
This commit is contained in:
parent
6f49808caa
commit
a4dce4340a
16
src/init.cpp
16
src/init.cpp
@ -58,7 +58,7 @@ CWallet* pwalletMain = NULL;
|
|||||||
int nWalletBackups = 10;
|
int nWalletBackups = 10;
|
||||||
#endif
|
#endif
|
||||||
bool fFeeEstimatesInitialized = false;
|
bool fFeeEstimatesInitialized = false;
|
||||||
bool wallet_restart = false; // true: restart false: shutdown
|
bool fRestartRequested = false; // true: restart false: shutdown
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
// Win32 LevelDB doesn't use filedescriptors, and the ones used for
|
// Win32 LevelDB doesn't use filedescriptors, and the ones used for
|
||||||
@ -145,9 +145,9 @@ static CCoinsViewDB *pcoinsdbview = NULL;
|
|||||||
static CCoinsViewErrorCatcher *pcoinscatcher = NULL;
|
static CCoinsViewErrorCatcher *pcoinscatcher = NULL;
|
||||||
|
|
||||||
/** Preparing steps before shutting down or restarting the wallet */
|
/** 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__);
|
LogPrintf("%s: In progress...\n", __func__);
|
||||||
static CCriticalSection cs_Shutdown;
|
static CCriticalSection cs_Shutdown;
|
||||||
TRY_LOCK(cs_Shutdown, lockShutdown);
|
TRY_LOCK(cs_Shutdown, lockShutdown);
|
||||||
@ -208,18 +208,18 @@ void Prepare_Shutdown()
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Shutdown is split into 2 parts:
|
* 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
|
* 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
|
* 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()
|
void Shutdown()
|
||||||
{
|
{
|
||||||
// Shutdown part 1: prepare shutdown
|
// Shutdown part 1: prepare shutdown
|
||||||
if(!wallet_restart){
|
if(!fRestartRequested){
|
||||||
Prepare_Shutdown();
|
PrepareShutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Shutdown part 2: delete wallet instance
|
// Shutdown part 2: delete wallet instance
|
||||||
|
@ -20,7 +20,7 @@ extern CWallet* pwalletMain;
|
|||||||
void StartShutdown();
|
void StartShutdown();
|
||||||
bool ShutdownRequested();
|
bool ShutdownRequested();
|
||||||
void Shutdown();
|
void Shutdown();
|
||||||
void Prepare_Shutdown();
|
void PrepareShutdown();
|
||||||
bool AppInit2(boost::thread_group& threadGroup);
|
bool AppInit2(boost::thread_group& threadGroup);
|
||||||
|
|
||||||
/** The help message mode determines what help message to show */
|
/** The help message mode determines what help message to show */
|
||||||
|
@ -357,7 +357,7 @@ void BitcoinGUI::createActions(const NetworkStyle *networkStyle)
|
|||||||
openNetworkAction->setStatusTip(tr("Show network monitor"));
|
openNetworkAction->setStatusTip(tr("Show network monitor"));
|
||||||
openPeersAction = new QAction(QIcon(":/icons/connect_4"), tr("&Peers list"), this);
|
openPeersAction = new QAction(QIcon(":/icons/connect_4"), tr("&Peers list"), this);
|
||||||
openPeersAction->setStatusTip(tr("Show peers info"));
|
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"));
|
openRepairAction->setStatusTip(tr("Repair Wallet Options"));
|
||||||
openConfEditorAction = new QAction(QIcon(":/icons/edit"), tr("Open &Configuration File"), this);
|
openConfEditorAction = new QAction(QIcon(":/icons/edit"), tr("Open &Configuration File"), this);
|
||||||
openConfEditorAction->setStatusTip(tr("Open configuration file"));
|
openConfEditorAction->setStatusTip(tr("Open configuration file"));
|
||||||
|
@ -282,13 +282,13 @@ void BitcoinCore::initialize()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void BitcoinCore::restart(QStringList args)
|
void BitcoinCore::restart(QStringList args)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
qDebug() << __func__ << ": Running Restart in thread";
|
qDebug() << __func__ << ": Running Restart in thread";
|
||||||
threadGroup.interrupt_all();
|
threadGroup.interrupt_all();
|
||||||
threadGroup.join_all();
|
threadGroup.join_all();
|
||||||
Prepare_Shutdown();
|
PrepareShutdown();
|
||||||
qDebug() << __func__ << ": Shutdown finished";
|
qDebug() << __func__ << ": Shutdown finished";
|
||||||
emit shutdownResult(1);
|
emit shutdownResult(1);
|
||||||
CExplicitNetCleanup::callCleanup();
|
CExplicitNetCleanup::callCleanup();
|
||||||
|
@ -1073,7 +1073,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>90</y>
|
<y>90</y>
|
||||||
<width>180</width>
|
<width>221</width>
|
||||||
<height>23</height>
|
<height>23</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -1092,7 +1092,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>140</y>
|
<y>140</y>
|
||||||
<width>180</width>
|
<width>221</width>
|
||||||
<height>23</height>
|
<height>23</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -1111,7 +1111,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>190</y>
|
<y>190</y>
|
||||||
<width>180</width>
|
<width>221</width>
|
||||||
<height>23</height>
|
<height>23</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -1130,7 +1130,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>240</y>
|
<y>240</y>
|
||||||
<width>180</width>
|
<width>221</width>
|
||||||
<height>23</height>
|
<height>23</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -1149,7 +1149,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>290</y>
|
<y>290</y>
|
||||||
<width>180</width>
|
<width>221</width>
|
||||||
<height>23</height>
|
<height>23</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -1188,9 +1188,9 @@
|
|||||||
<widget class="QLabel" name="label_repair_salvage">
|
<widget class="QLabel" name="label_repair_salvage">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>210</x>
|
<x>250</x>
|
||||||
<y>80</y>
|
<y>80</y>
|
||||||
<width>511</width>
|
<width>471</width>
|
||||||
<height>41</height>
|
<height>41</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -1204,9 +1204,9 @@
|
|||||||
<widget class="QLabel" name="label_repair_rescan">
|
<widget class="QLabel" name="label_repair_rescan">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>210</x>
|
<x>250</x>
|
||||||
<y>129</y>
|
<y>129</y>
|
||||||
<width>511</width>
|
<width>471</width>
|
||||||
<height>41</height>
|
<height>41</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -1220,9 +1220,9 @@
|
|||||||
<widget class="QLabel" name="label_repair_zap1">
|
<widget class="QLabel" name="label_repair_zap1">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>210</x>
|
<x>250</x>
|
||||||
<y>179</y>
|
<y>179</y>
|
||||||
<width>511</width>
|
<width>471</width>
|
||||||
<height>41</height>
|
<height>41</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -1236,9 +1236,9 @@
|
|||||||
<widget class="QLabel" name="label_repair_zap2">
|
<widget class="QLabel" name="label_repair_zap2">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>210</x>
|
<x>250</x>
|
||||||
<y>229</y>
|
<y>229</y>
|
||||||
<width>511</width>
|
<width>471</width>
|
||||||
<height>41</height>
|
<height>41</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -1252,14 +1252,14 @@
|
|||||||
<widget class="QLabel" name="label_repair_upgrade">
|
<widget class="QLabel" name="label_repair_upgrade">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>210</x>
|
<x>250</x>
|
||||||
<y>279</y>
|
<y>279</y>
|
||||||
<width>511</width>
|
<width>471</width>
|
||||||
<height>41</height>
|
<height>41</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>-upgradewallet: Upgrade wallet to latest format on startup. (Note: this is NOT an update of the wallet itself !)</string>
|
<string>-upgradewallet: Upgrade wallet to latest format on startup. (Note: this is NOT an update of the wallet itself!)</string>
|
||||||
</property>
|
</property>
|
||||||
<property name="wordWrap">
|
<property name="wordWrap">
|
||||||
<bool>true</bool>
|
<bool>true</bool>
|
||||||
@ -1293,7 +1293,7 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>10</x>
|
<x>10</x>
|
||||||
<y>340</y>
|
<y>340</y>
|
||||||
<width>181</width>
|
<width>221</width>
|
||||||
<height>23</height>
|
<height>23</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
@ -1304,9 +1304,9 @@
|
|||||||
<widget class="QLabel" name="label_repair_reindex">
|
<widget class="QLabel" name="label_repair_reindex">
|
||||||
<property name="geometry">
|
<property name="geometry">
|
||||||
<rect>
|
<rect>
|
||||||
<x>210</x>
|
<x>250</x>
|
||||||
<y>330</y>
|
<y>330</y>
|
||||||
<width>511</width>
|
<width>471</width>
|
||||||
<height>41</height>
|
<height>41</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
|
@ -42,6 +42,14 @@ const QSize ICON_SIZE(24, 24);
|
|||||||
|
|
||||||
const int INITIAL_TRAFFIC_GRAPH_MINS = 30;
|
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 struct {
|
||||||
const char *url;
|
const char *url;
|
||||||
const char *source;
|
const char *source;
|
||||||
@ -222,12 +230,12 @@ RPCConsole::RPCConsole(QWidget *parent) :
|
|||||||
connect(ui->btnClearTrafficGraph, SIGNAL(clicked()), ui->trafficGraph, SLOT(clear()));
|
connect(ui->btnClearTrafficGraph, SIGNAL(clicked()), ui->trafficGraph, SLOT(clear()));
|
||||||
|
|
||||||
// Wallet Repair Buttons
|
// Wallet Repair Buttons
|
||||||
connect(ui->btn_salvagewallet, SIGNAL(clicked()), this, SLOT(wallet_salvage()));
|
connect(ui->btn_salvagewallet, SIGNAL(clicked()), this, SLOT(walletSalvage()));
|
||||||
connect(ui->btn_rescan, SIGNAL(clicked()), this, SLOT(wallet_rescan()));
|
connect(ui->btn_rescan, SIGNAL(clicked()), this, SLOT(walletRescan()));
|
||||||
connect(ui->btn_zapwallettxes1, SIGNAL(clicked()), this, SLOT(wallet_zaptxes1()));
|
connect(ui->btn_zapwallettxes1, SIGNAL(clicked()), this, SLOT(walletZaptxes1()));
|
||||||
connect(ui->btn_zapwallettxes2, SIGNAL(clicked()), this, SLOT(wallet_zaptxes2()));
|
connect(ui->btn_zapwallettxes2, SIGNAL(clicked()), this, SLOT(walletZaptxes2()));
|
||||||
connect(ui->btn_upgradewallet, SIGNAL(clicked()), this, SLOT(wallet_upgrade()));
|
connect(ui->btn_upgradewallet, SIGNAL(clicked()), this, SLOT(walletUpgrade()));
|
||||||
connect(ui->btn_reindex, SIGNAL(clicked()), this, SLOT(wallet_reindex()));
|
connect(ui->btn_reindex, SIGNAL(clicked()), this, SLOT(walletReindex()));
|
||||||
|
|
||||||
// set library version labels
|
// set library version labels
|
||||||
ui->openSSLVersion->setText(SSLeay_version(SSLEAY_VERSION));
|
ui->openSSLVersion->setText(SSLeay_version(SSLEAY_VERSION));
|
||||||
@ -345,49 +353,59 @@ static QString categoryClass(int category)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Restart wallet with "-salvagewallet" */
|
/** Restart wallet with "-salvagewallet" */
|
||||||
void RPCConsole::wallet_salvage()
|
void RPCConsole::walletSalvage()
|
||||||
{
|
{
|
||||||
build_parameter_list(QString("-salvagewallet"));
|
buildParameterlist(SALVAGEWALLET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Restart wallet with "-rescan" */
|
/** Restart wallet with "-rescan" */
|
||||||
void RPCConsole::wallet_rescan()
|
void RPCConsole::walletRescan()
|
||||||
{
|
{
|
||||||
build_parameter_list(QString("-rescan"));
|
buildParameterlist(RESCAN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Restart wallet with "-zapwallettxes=1" */
|
/** 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" */
|
/** Restart wallet with "-zapwallettxes=2" */
|
||||||
void RPCConsole::wallet_zaptxes2()
|
void RPCConsole::walletZaptxes2()
|
||||||
{
|
{
|
||||||
build_parameter_list(QString("-zapwallettxes=2"));
|
buildParameterlist(ZAPTXES2);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Restart wallet with "-upgradewallet" */
|
/** Restart wallet with "-upgradewallet" */
|
||||||
void RPCConsole::wallet_upgrade()
|
void RPCConsole::walletUpgrade()
|
||||||
{
|
{
|
||||||
build_parameter_list(QString("-upgradewallet"));
|
buildParameterlist(UPGRADEWALLET);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Restart wallet with "-reindex" */
|
/** 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 */
|
/** 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
|
// Get command-line arguments and remove the application name
|
||||||
QStringList args = QApplication::arguments();
|
QStringList args = QApplication::arguments();
|
||||||
args.removeFirst();
|
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
|
// Append repair parameter to command line. We don't care whether it might already be there
|
||||||
args.append(arg);
|
args.append(arg);
|
||||||
|
|
||||||
// Send command-line arguments to BitcoinGUI::handleRestart()
|
// Send command-line arguments to BitcoinGUI::handleRestart()
|
||||||
emit handleRestart(args);
|
emit handleRestart(args);
|
||||||
}
|
}
|
||||||
|
@ -61,12 +61,12 @@ public slots:
|
|||||||
void clear();
|
void clear();
|
||||||
|
|
||||||
/** Wallet repair options */
|
/** Wallet repair options */
|
||||||
void wallet_salvage();
|
void walletSalvage();
|
||||||
void wallet_rescan();
|
void walletRescan();
|
||||||
void wallet_zaptxes1();
|
void walletZaptxes1();
|
||||||
void wallet_zaptxes2();
|
void walletZaptxes2();
|
||||||
void wallet_upgrade();
|
void walletUpgrade();
|
||||||
void wallet_reindex();
|
void walletReindex();
|
||||||
|
|
||||||
void reject();
|
void reject();
|
||||||
void message(int category, const QString &message, bool html = false);
|
void message(int category, const QString &message, bool html = false);
|
||||||
@ -111,7 +111,7 @@ private:
|
|||||||
void startExecutor();
|
void startExecutor();
|
||||||
void setTrafficGraphRange(int mins);
|
void setTrafficGraphRange(int mins);
|
||||||
/** Build parameter list for restart */
|
/** Build parameter list for restart */
|
||||||
void build_parameter_list(QString arg);
|
void buildParameterlist(QString arg);
|
||||||
/** show detailed information on ui about selected node */
|
/** show detailed information on ui about selected node */
|
||||||
void updateNodeDetail(const CNodeCombinedStats *stats);
|
void updateNodeDetail(const CNodeCombinedStats *stats);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user