diff options
| author | stoffu <stoffu@protonmail.ch> | 2018-03-06 01:19:45 +0900 |
|---|---|---|
| committer | stoffu <stoffu@protonmail.ch> | 2018-03-14 23:26:25 +0900 |
| commit | c8f0cf354390af1908b3f99e5621eed8c1fab9ed (patch) | |
| tree | 4e60f827c875a1222e93d7eb349b4badfd836b2f /src/daemon/DaemonManager.cpp | |
| parent | c5363da1e8ffb2c8f5d9a6fb7fd00485277fc0aa (diff) | |
| download | monzero-gui-c8f0cf354390af1908b3f99e5621eed8c1fab9ed.tar.gz monzero-gui-c8f0cf354390af1908b3f99e5621eed8c1fab9ed.tar.xz monzero-gui-c8f0cf354390af1908b3f99e5621eed8c1fab9ed.zip | |
Stagenet
Diffstat (limited to 'src/daemon/DaemonManager.cpp')
| -rw-r--r-- | src/daemon/DaemonManager.cpp | 44 |
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; |
