From 66e3fbdf5c2e4e35a4a465522705cc6b86898af0 Mon Sep 17 00:00:00 2001 From: DenioD <41270280+DenioD@users.noreply.github.com> Date: Mon, 13 Apr 2020 23:30:09 +0200 Subject: [PATCH] add consolidation,deletetx and zindex as checkbox to Settings/Troubleshooting --- src/connection.cpp | 16 +++++++-- src/connection.h | 3 ++ src/mainwindow.cpp | 85 +++++++++++++++++++++++++++++++++++++++++++--- 3 files changed, 97 insertions(+), 7 deletions(-) diff --git a/src/connection.cpp b/src/connection.cpp index 9a1cd01..8016f6f 100644 --- a/src/connection.cpp +++ b/src/connection.cpp @@ -656,6 +656,7 @@ std::shared_ptr ConnectionLoader::autoDetectZcashConf() { zcashconf->usingZcashConf = true; zcashconf->zcashDir = QFileInfo(confLocation).absoluteDir().absolutePath(); zcashconf->zcashDaemon = false; + Settings::getInstance()->setUsingZcashConf(confLocation); @@ -679,6 +680,15 @@ std::shared_ptr ConnectionLoader::autoDetectZcashConf() { } if (name == "proxy") { zcashconf->proxy = value; + } + if (name == "consolidation") { + zcashconf->consolidation = value; + } + if (name == "deletetx") { + zcashconf->deletetx = value; + } + if (name == "zindex") { + zcashconf->zindex = value; } if (name == "testnet" && value == "1" && @@ -706,12 +716,12 @@ std::shared_ptr ConnectionLoader::loadFromSettings() { auto host = s.value("connection/host").toString(); auto port = s.value("connection/port").toString(); auto username = s.value("connection/rpcuser").toString(); - auto password = s.value("connection/rpcpassword").toString(); - + auto password = s.value("connection/rpcpassword").toString(); + if (username.isEmpty() || password.isEmpty()) return nullptr; - auto uiConfig = new ConnectionConfig{ host, port, username, password, false, false, "", "", ConnectionType::UISettingsZCashD}; + auto uiConfig = new ConnectionConfig{ host, port, username, password, false, false,"","" "", "","","", ConnectionType::UISettingsZCashD}; return std::shared_ptr(uiConfig); } diff --git a/src/connection.h b/src/connection.h index e192d49..dc0a54d 100644 --- a/src/connection.h +++ b/src/connection.h @@ -24,6 +24,9 @@ struct ConnectionConfig { bool zcashDaemon; QString zcashDir; QString proxy; + QString consolidation; + QString deletetx; + QString zindex; ConnectionType connType; }; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 8b37e24..8355cbb 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -350,6 +350,40 @@ void MainWindow::setupSettingsModal() { settings.lblTor->setToolTip(tooltip); } + //Use Consolidation + + bool isUsingConsolidation = false; + if (rpc->getConnection() != nullptr) { + isUsingConsolidation = !rpc->getConnection()->config->consolidation.isEmpty() == true; + } + settings.chkConso->setChecked(isUsingConsolidation); + if (rpc->getEZcashD() == nullptr) { + settings.chkConso->setEnabled(false); + } + + + //Use Deletetx + + bool isUsingDeletetx = false; + if (rpc->getConnection() != nullptr) { + isUsingDeletetx = !rpc->getConnection()->config->deletetx.isEmpty() == true; + } + settings.chkDeletetx->setChecked(isUsingDeletetx); + if (rpc->getEZcashD() == nullptr) { + settings.chkDeletetx->setEnabled(false); + } + + //Use Zindex + + bool isUsingZindex = false; + if (rpc->getConnection() != nullptr) { + isUsingZindex = !rpc->getConnection()->config->zindex.isEmpty() == true; + } + settings.chkzindex->setChecked(isUsingZindex); + if (rpc->getEZcashD() == nullptr) { + settings.chkzindex->setEnabled(false); + } + // Connection Settings QIntValidator validator(0, 65535); settings.port->setValidator(&validator); @@ -361,16 +395,15 @@ void MainWindow::setupSettingsModal() { settings.hostname->setEnabled(false); settings.port->setEnabled(false); settings.rpcuser->setEnabled(false); - settings.rpcpassword->setEnabled(false); + settings.rpcpassword->setEnabled(false); } else { settings.confMsg->setText("No local HUSH3.conf found. Please configure connection manually."); settings.hostname->setEnabled(true); settings.port->setEnabled(true); settings.rpcuser->setEnabled(true); - settings.rpcpassword->setEnabled(true); + settings.rpcpassword->setEnabled(true); } - // Load current values into the dialog // Load current values into the dialog auto conf = Settings::getInstance()->getSettings(); settings.hostname->setText(conf.host); @@ -466,8 +499,52 @@ void MainWindow::setupSettingsModal() { showRestartInfo = true; } + if (!rpc->getConnection()->config->consolidation.isEmpty()==false) { + if (settings.chkConso->isChecked()) { + Settings::addToZcashConf(zcashConfLocation, "consolidation=1"); + showRestartInfo = true; + } + } + + if (!rpc->getConnection()->config->consolidation.isEmpty()) { + if (settings.chkConso->isChecked() == false) { + Settings::removeFromZcashConf(zcashConfLocation, "consolidation"); + showRestartInfo = true; + } + } + + if (!rpc->getConnection()->config->deletetx.isEmpty() == false) { + if (settings.chkDeletetx->isChecked()) { + Settings::addToZcashConf(zcashConfLocation, "deletetx=1"); + showRestartInfo = true; + } + } + + if (!rpc->getConnection()->config->deletetx.isEmpty()) { + if (settings.chkDeletetx->isChecked() == false) { + Settings::removeFromZcashConf(zcashConfLocation, "deletetx"); + showRestartInfo = true; + } + } + + if (!rpc->getConnection()->config->zindex.isEmpty() == false) { + if (settings.chkzindex->isChecked()) { + Settings::addToZcashConf(zcashConfLocation, "zindex=1"); + Settings::addToZcashConf(zcashConfLocation, "reindex=1"); + showRestartInfo = true; + } + } + + if (!rpc->getConnection()->config->zindex.isEmpty()) { + if (settings.chkzindex->isChecked() == false) { + Settings::removeFromZcashConf(zcashConfLocation, "zindex"); + Settings::addToZcashConf(zcashConfLocation, "reindex=1"); + showRestartInfo = true; + } + } + if (showRestartInfo) { - auto desc = tr("SilentDragon needs to restart to rescan/reindex. SilentDragon will now close, please restart SilentDragon to continue"); + auto desc = tr("SilentDragon needs to restart to rescan,reindex,consolidation or deletetx. SilentDragon will now close, please restart SilentDragon to continue"); QMessageBox::information(this, tr("Restart SilentDragon"), desc, QMessageBox::Ok); QTimer::singleShot(1, [=]() { this->close(); });