#49 - Handle zcashd set to daemon=1
This commit is contained in:
@@ -53,25 +53,38 @@ void ConnectionLoader::doAutoConnect(bool tryEzcashdStart) {
|
|||||||
main->logger->write("Embedded zcashd started up, trying autoconnect in 1 sec");
|
main->logger->write("Embedded zcashd started up, trying autoconnect in 1 sec");
|
||||||
QTimer::singleShot(1000, [=]() { doAutoConnect(); } );
|
QTimer::singleShot(1000, [=]() { doAutoConnect(); } );
|
||||||
} else {
|
} else {
|
||||||
// Something is wrong. This is happenening intermittently on Mac platforms.
|
if (config->zcashDaemon) {
|
||||||
// - We tried to start zcashd
|
// zcashd is configured to run as a daemon, so we must wait for a few seconds
|
||||||
// - QProcess started
|
// to let it start up.
|
||||||
// - QProcess ended, but the embedded zcashd is still in the background.
|
main->logger->write("zcashd is daemon=1. Waiting for it to start up");
|
||||||
// We're going to attempt to connect to the one in the background one last time
|
this->showInformation("zcashd is set to run as daemon", "Waiting for zcashd");
|
||||||
// and see if that works, else throw an error
|
QTimer::singleShot(5000, [=]() { doAutoConnect(/* don't attempt to start ezcashd */ false); });
|
||||||
main->logger->write("Something is wrong, trying no-retry autoconnect in 2 sec");
|
} else {
|
||||||
QTimer::singleShot(2000, [=]() { doAutoConnect(/* don't attempt to start ezcashd */ false); });
|
// Something is wrong.
|
||||||
|
// We're going to attempt to connect to the one in the background one last time
|
||||||
|
// and see if that works, else throw an error
|
||||||
|
main->logger->write("Unknown problem while trying to start zcashd");
|
||||||
|
QTimer::singleShot(2000, [=]() { doAutoConnect(/* don't attempt to start ezcashd */ false); });
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// We tried to start ezcashd previously, and it didn't work. So, show the error.
|
// We tried to start ezcashd previously, and it didn't work. So, show the error.
|
||||||
main->logger->write("Couldn't start embedded zcashd for unknown reason");
|
main->logger->write("Couldn't start embedded zcashd for unknown reason");
|
||||||
QString explanation = QString() % "Couldn't start the embedded zcashd.\n\n" %
|
QString explanation;
|
||||||
"Please try restarting.\n\nIf you previously started zcashd with custom arguments, you might need to reset zcash.conf.\n\n" %
|
if (config->zcashDaemon) {
|
||||||
"If all else fails, please run zcashd manually." %
|
explanation = QString() % "You have zcashd set to start as a daemon, which can cause problems "
|
||||||
(ezcashd ? "The process returned:\n\n" % ezcashd->errorString() : QString(""));
|
"with zec-qt-wallet\n\n."
|
||||||
|
"Please remove the following line from your zcash.conf and restart zec-qt-wallet\n"
|
||||||
|
"daemon=1";
|
||||||
|
} else {
|
||||||
|
explanation = QString() % "Couldn't start the embedded zcashd.\n\n" %
|
||||||
|
"Please try restarting.\n\nIf you previously started zcashd with custom arguments, you might need to reset zcash.conf.\n\n" %
|
||||||
|
"If all else fails, please run zcashd manually." %
|
||||||
|
(ezcashd ? "The process returned:\n\n" % ezcashd->errorString() : QString(""));
|
||||||
|
}
|
||||||
|
|
||||||
this->showError(explanation);
|
this->showError(explanation);
|
||||||
}
|
}
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// zcash.conf exists, there's no connection, and the user asked us not to start zcashd. Error!
|
// zcash.conf exists, there's no connection, and the user asked us not to start zcashd. Error!
|
||||||
main->logger->write("Not using embedded and couldn't connect to zcashd");
|
main->logger->write("Not using embedded and couldn't connect to zcashd");
|
||||||
@@ -255,7 +268,6 @@ bool ConnectionLoader::startEmbeddedZcashd() {
|
|||||||
|
|
||||||
if (ezcashd != nullptr) {
|
if (ezcashd != nullptr) {
|
||||||
if (ezcashd->state() == QProcess::NotRunning) {
|
if (ezcashd->state() == QProcess::NotRunning) {
|
||||||
qDebug() << "Process started and then crashed";
|
|
||||||
if (!processStdErrOutput.isEmpty()) {
|
if (!processStdErrOutput.isEmpty()) {
|
||||||
QMessageBox::critical(main, "zcashd error", "zcashd said: " + processStdErrOutput,
|
QMessageBox::critical(main, "zcashd error", "zcashd said: " + processStdErrOutput,
|
||||||
QMessageBox::Ok);
|
QMessageBox::Ok);
|
||||||
@@ -516,6 +528,7 @@ std::shared_ptr<ConnectionConfig> ConnectionLoader::autoDetectZcashConf() {
|
|||||||
zcashconf->connType = ConnectionType::DetectedConfExternalZcashD;
|
zcashconf->connType = ConnectionType::DetectedConfExternalZcashD;
|
||||||
zcashconf->usingZcashConf = true;
|
zcashconf->usingZcashConf = true;
|
||||||
zcashconf->zcashDir = QFileInfo(confLocation).absoluteDir().absolutePath();
|
zcashconf->zcashDir = QFileInfo(confLocation).absoluteDir().absolutePath();
|
||||||
|
zcashconf->zcashDaemon = false;
|
||||||
|
|
||||||
Settings::getInstance()->setUsingZcashConf(confLocation);
|
Settings::getInstance()->setUsingZcashConf(confLocation);
|
||||||
|
|
||||||
@@ -534,6 +547,9 @@ std::shared_ptr<ConnectionConfig> ConnectionLoader::autoDetectZcashConf() {
|
|||||||
if (name == "rpcport") {
|
if (name == "rpcport") {
|
||||||
zcashconf->port = value;
|
zcashconf->port = value;
|
||||||
}
|
}
|
||||||
|
if (name == "daemon" && value == "1") {
|
||||||
|
zcashconf->zcashDaemon = true;
|
||||||
|
}
|
||||||
if (name == "testnet" &&
|
if (name == "testnet" &&
|
||||||
value == "1" &&
|
value == "1" &&
|
||||||
zcashconf->port.isEmpty()) {
|
zcashconf->port.isEmpty()) {
|
||||||
@@ -565,7 +581,7 @@ std::shared_ptr<ConnectionConfig> ConnectionLoader::loadFromSettings() {
|
|||||||
if (username.isEmpty() || password.isEmpty())
|
if (username.isEmpty() || password.isEmpty())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
auto uiConfig = new ConnectionConfig{ host, port, username, password, false, "", ConnectionType::UISettingsZCashD};
|
auto uiConfig = new ConnectionConfig{ host, port, username, password, false, false, "", ConnectionType::UISettingsZCashD};
|
||||||
|
|
||||||
return std::shared_ptr<ConnectionConfig>(uiConfig);
|
return std::shared_ptr<ConnectionConfig>(uiConfig);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ struct ConnectionConfig {
|
|||||||
QString rpcuser;
|
QString rpcuser;
|
||||||
QString rpcpassword;
|
QString rpcpassword;
|
||||||
bool usingZcashConf;
|
bool usingZcashConf;
|
||||||
|
bool zcashDaemon;
|
||||||
QString zcashDir;
|
QString zcashDir;
|
||||||
|
|
||||||
ConnectionType connType;
|
ConnectionType connType;
|
||||||
|
|||||||
@@ -940,8 +940,10 @@ void RPC::shutdownZcashd() {
|
|||||||
int waitCount = 0;
|
int waitCount = 0;
|
||||||
QObject::connect(&waiter, &QTimer::timeout, [&] () {
|
QObject::connect(&waiter, &QTimer::timeout, [&] () {
|
||||||
waitCount++;
|
waitCount++;
|
||||||
|
|
||||||
if ((ezcashd->atEnd() && ezcashd->processId() == 0) ||
|
if ((ezcashd->atEnd() && ezcashd->processId() == 0) ||
|
||||||
waitCount > 30) {
|
waitCount > 30 ||
|
||||||
|
conn->config->zcashDaemon) { // If zcashd is daemon, then we don't have to do anything else
|
||||||
qDebug() << "Ended";
|
qDebug() << "Ended";
|
||||||
waiter.stop();
|
waiter.stop();
|
||||||
QTimer::singleShot(1000, [&]() { d.accept(); });
|
QTimer::singleShot(1000, [&]() { d.accept(); });
|
||||||
|
|||||||
Reference in New Issue
Block a user