aboutsummaryrefslogtreecommitdiff
path: root/src/p2pool/P2PoolManager.cpp
diff options
context:
space:
mode:
authorluigi1111 <luigi1111w@gmail.com>2022-06-09 16:30:45 -0500
committerluigi1111 <luigi1111w@gmail.com>2022-06-09 16:30:45 -0500
commit96cca79b709dce3887f5dfac42abe111faaae01e (patch)
tree62beac3eda19512d1367448cf376ff88719c7da9 /src/p2pool/P2PoolManager.cpp
parent3f3eb643e48086f7ea70bbbccd1bab0ea5c684a3 (diff)
parent432650008c4af92db138041d15b06e43fba0b7ab (diff)
downloadmonzero-gui-96cca79b709dce3887f5dfac42abe111faaae01e.tar.gz
monzero-gui-96cca79b709dce3887f5dfac42abe111faaae01e.tar.xz
monzero-gui-96cca79b709dce3887f5dfac42abe111faaae01e.zip
Merge pull request #3933
4326500 Use p2pool folder for p2pool on Windows (SChernykh)
Diffstat (limited to 'src/p2pool/P2PoolManager.cpp')
-rw-r--r--src/p2pool/P2PoolManager.cpp29
1 files changed, 17 insertions, 12 deletions
diff --git a/src/p2pool/P2PoolManager.cpp b/src/p2pool/P2PoolManager.cpp
index 7f9e2a4f..4d4a2e8f 100644
--- a/src/p2pool/P2PoolManager.cpp
+++ b/src/p2pool/P2PoolManager.cpp
@@ -50,15 +50,15 @@ void P2PoolManager::download() {
QString validHash;
#ifdef Q_OS_WIN
url = "https://github.com/SChernykh/p2pool/releases/download/v1.9/p2pool-v1.9-windows-x64.zip";
- fileName = "p2pool-v1.9-windows-x64.zip";
+ fileName = m_p2poolPath + "/p2pool-v1.9-windows-x64.zip";
validHash = "2587903dc04a4879dca2b6f5c5b584e869928e716274a7660e24b219c9f18839";
#elif defined(Q_OS_LINUX)
url = "https://github.com/SChernykh/p2pool/releases/download/v1.9/p2pool-v1.9-linux-x64.tar.gz";
- fileName = "p2pool-v1.9-linux-x64.tar.gz";
+ fileName = m_p2poolPath + "/p2pool-v1.9-linux-x64.tar.gz";
validHash = "0cd85d933ac4a76708d326698d9db3155bb29d0be82984c735fabd9e9a351b8e";
#elif defined(Q_OS_MACOS)
url = "https://github.com/SChernykh/p2pool/releases/download/v1.9/p2pool-v1.9-macos-x64.tar.gz";
- fileName = "p2pool-v1.9-macos-x64.tar.gz";
+ fileName = m_p2poolPath + "/p2pool-v1.9-macos-x64.tar.gz";
validHash = "47fbdd69d719da80597dd5487f109b61e30b540499cced7b93de1ee01344351e";
#endif
QFile file(fileName);
@@ -96,7 +96,7 @@ void P2PoolManager::download() {
file.open(QIODevice::WriteOnly);
file.write(data);
file.close();
- QProcess::execute("tar", {"-xzf", fileName, "--strip=1", "-C", QApplication::applicationDirPath()});
+ QProcess::execute("tar", {"-xzf", fileName, "--strip=1", "-C", m_p2poolPath});
QFile::remove(fileName);
if (isInstalled()) {
emit p2poolDownloadSuccess();
@@ -119,7 +119,7 @@ bool P2PoolManager::isInstalled() {
}
void P2PoolManager::getStatus() {
- QString statsPath = QApplication::applicationDirPath() + "/stats/local/miner";
+ QString statsPath = m_p2poolPath + "/stats/local/miner";
bool status = true;
if (!QFileInfo(statsPath).isFile() || !started)
{
@@ -158,7 +158,7 @@ bool P2PoolManager::start(const QString &flags, const QString &address, const QS
if (!arguments.contains("--data-api")) {
QDir dir;
- QString dirName = QApplication::applicationDirPath() + "/stats/";
+ QString dirName = m_p2poolPath + "/stats/";
QDir statsDir(dirName);
if (dir.exists(dirName)) {
statsDir.removeRecursively();
@@ -170,7 +170,7 @@ bool P2PoolManager::start(const QString &flags, const QString &address, const QS
if (!arguments.contains("--start-mining")) {
arguments << "--start-mining" << threads;
}
-
+
if (chain == "mini") {
arguments << "--mini";
}
@@ -178,7 +178,7 @@ bool P2PoolManager::start(const QString &flags, const QString &address, const QS
if (!arguments.contains("--wallet")) {
arguments << "--wallet" << address;
}
-
+
qDebug() << "starting p2pool " + m_p2pool;
qDebug() << "With command line arguments " << arguments;
@@ -189,7 +189,7 @@ bool P2PoolManager::start(const QString &flags, const QString &address, const QS
// Set program parameters
m_p2poold->setProgram(m_p2pool);
m_p2poold->setArguments(arguments);
- m_p2poold->setWorkingDirectory(QApplication::applicationDirPath());
+ m_p2poold->setWorkingDirectory(m_p2poolPath);
// Start p2pool
started = m_p2poold->startDetached();
@@ -213,7 +213,7 @@ void P2PoolManager::exit()
QProcess::execute("pkill", {"p2pool"});
#endif
started = false;
- QString dirName = QApplication::applicationDirPath() + "/stats/";
+ QString dirName = m_p2poolPath + "/stats/";
QDir dir(dirName);
dir.removeRecursively();
}
@@ -226,9 +226,14 @@ P2PoolManager::P2PoolManager(QObject *parent)
started = false;
// Platform dependent path to p2pool
#ifdef Q_OS_WIN
- m_p2pool = QApplication::applicationDirPath() + "/p2pool.exe";
+ m_p2poolPath = QApplication::applicationDirPath() + "/p2pool";
+ if (!QDir(m_p2poolPath).exists()) {
+ QDir().mkdir(m_p2poolPath);
+ }
+ m_p2pool = m_p2poolPath + "/p2pool.exe";
#elif defined(Q_OS_UNIX)
- m_p2pool = QApplication::applicationDirPath() + "/p2pool";
+ m_p2poolPath = QApplication::applicationDirPath();
+ m_p2pool = m_p2poolPath + "/p2pool";
#endif
if (m_p2pool.length() == 0) {
qCritical() << "no p2pool binary defined for current platform";