aboutsummaryrefslogtreecommitdiff
path: root/src/daemon/DaemonManager.cpp
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2018-03-26 12:57:14 -0500
committerluigi1111 <luigi1111w@gmail.com>2018-03-26 12:57:14 -0500
commite4d75c6680bb3ed7bccdf00e8e319b25b6a7be21 (patch)
tree593b10a28ca322ae36d582df236663f7e2a3f681 /src/daemon/DaemonManager.cpp
parent278458bb646cbb0d4361106cff424807812e5bda (diff)
parentc8f0cf354390af1908b3f99e5621eed8c1fab9ed (diff)
downloadmonzero-gui-e4d75c6680bb3ed7bccdf00e8e319b25b6a7be21.tar.gz
monzero-gui-e4d75c6680bb3ed7bccdf00e8e319b25b6a7be21.tar.xz
monzero-gui-e4d75c6680bb3ed7bccdf00e8e319b25b6a7be21.zip
Merge pull request #1161
c8f0cf3 Stagenet
Diffstat (limited to 'src/daemon/DaemonManager.cpp')
-rw-r--r--src/daemon/DaemonManager.cpp44
1 files changed, 22 insertions, 22 deletions
diff --git a/src/daemon/DaemonManager.cpp b/src/daemon/DaemonManager.cpp
index 93e7a9a8..79db8cff 100644
--- a/src/daemon/DaemonManager.cpp
+++ b/src/daemon/DaemonManager.cpp
@@ -32,7 +32,7 @@ DaemonManager *DaemonManager::instance(const QStringList *args)
return m_instance;
}
-bool DaemonManager::start(const QString &flags, bool testnet, const QString &dataDir, const QString &bootstrapNodeAddress)
+bool DaemonManager::start(const QString &flags, NetworkType::Type nettype, const QString &dataDir, const QString &bootstrapNodeAddress)
{
// prepare command line arguments and pass to monerod
QStringList arguments;
@@ -42,8 +42,10 @@ bool DaemonManager::start(const QString &flags, bool testnet, const QString &dat
arguments << "--detach";
#endif
- if(testnet)
+ if (nettype == NetworkType::TESTNET)
arguments << "--testnet";
+ else if (nettype == NetworkType::STAGENET)
+ arguments << "--stagenet";
foreach (const QString &str, m_clArgs) {
qDebug() << QString(" [%1] ").arg(str);
@@ -60,11 +62,7 @@ bool DaemonManager::start(const QString &flags, bool testnet, const QString &dat
// Custom data-dir
if(!dataDir.isEmpty()) {
- if(testnet)
- arguments << "--testnet-data-dir";
- else
- arguments << "--data-dir";
- arguments << dataDir;
+ arguments << "--data-dir" << dataDir;
}
// Bootstrap node address
@@ -99,7 +97,7 @@ bool DaemonManager::start(const QString &flags, bool testnet, const QString &dat
}
// Start start watcher
- QFuture<bool> future = QtConcurrent::run(this, &DaemonManager::startWatcher, testnet);
+ QFuture<bool> future = QtConcurrent::run(this, &DaemonManager::startWatcher, nettype);
QFutureWatcher<bool> * watcher = new QFutureWatcher<bool>();
connect(watcher, &QFutureWatcher<bool>::finished,
this, [this, watcher]() {
@@ -116,14 +114,14 @@ bool DaemonManager::start(const QString &flags, bool testnet, const QString &dat
return true;
}
-bool DaemonManager::stop(bool testnet)
+bool DaemonManager::stop(NetworkType::Type nettype)
{
QString message;
- sendCommand("exit",testnet,message);
+ sendCommand("exit", nettype, message);
qDebug() << message;
// Start stop watcher - Will kill if not shutting down
- QFuture<bool> future = QtConcurrent::run(this, &DaemonManager::stopWatcher, testnet);
+ QFuture<bool> future = QtConcurrent::run(this, &DaemonManager::stopWatcher, nettype);
QFutureWatcher<bool> * watcher = new QFutureWatcher<bool>();
connect(watcher, &QFutureWatcher<bool>::finished,
this, [this, watcher]() {
@@ -138,14 +136,14 @@ bool DaemonManager::stop(bool testnet)
return true;
}
-bool DaemonManager::startWatcher(bool testnet) const
+bool DaemonManager::startWatcher(NetworkType::Type nettype) const
{
// Check if daemon is started every 2 seconds
QTime timer;
timer.restart();
while(true && !m_app_exit && timer.elapsed() / 1000 < DAEMON_START_TIMEOUT_SECONDS ) {
QThread::sleep(2);
- if(!running(testnet)) {
+ if(!running(nettype)) {
qDebug() << "daemon not running. checking again in 2 seconds.";
} else {
qDebug() << "daemon is started. Waiting 5 seconds to let daemon catch up";
@@ -156,14 +154,14 @@ bool DaemonManager::startWatcher(bool testnet) const
return false;
}
-bool DaemonManager::stopWatcher(bool testnet) const
+bool DaemonManager::stopWatcher(NetworkType::Type nettype) const
{
// Check if daemon is running every 2 seconds. Kill if still running after 10 seconds
int counter = 0;
while(true && !m_app_exit) {
QThread::sleep(2);
counter++;
- if(running(testnet)) {
+ if(running(nettype)) {
qDebug() << "Daemon still running. " << counter;
if(counter >= 5) {
qDebug() << "Killing it! ";
@@ -211,10 +209,10 @@ void DaemonManager::printError()
}
}
-bool DaemonManager::running(bool testnet) const
+bool DaemonManager::running(NetworkType::Type nettype) const
{
QString status;
- sendCommand("status",testnet, status);
+ sendCommand("status", nettype, status);
qDebug() << status;
// `./monerod status` returns BUSY when syncing.
// Treat busy as connected, until fixed upstream.
@@ -223,21 +221,23 @@ bool DaemonManager::running(bool testnet) const
}
return false;
}
-bool DaemonManager::sendCommand(const QString &cmd,bool testnet) const
+bool DaemonManager::sendCommand(const QString &cmd, NetworkType::Type nettype) const
{
QString message;
- return sendCommand(cmd, testnet, message);
+ return sendCommand(cmd, nettype, message);
}
-bool DaemonManager::sendCommand(const QString &cmd,bool testnet, QString &message) const
+bool DaemonManager::sendCommand(const QString &cmd, NetworkType::Type nettype, QString &message) const
{
QProcess p;
QStringList external_cmd;
external_cmd << cmd;
- // Add testnet flag if needed
- if (testnet)
+ // Add network type flag if needed
+ if (nettype == NetworkType::TESTNET)
external_cmd << "--testnet";
+ else if (nettype == NetworkType::STAGENET)
+ external_cmd << "--stagenet";
qDebug() << "sending external cmd: " << external_cmd;