Use `p2pool` folder for p2pool on Windows

And set the correct file permissions on it so it can be run without administrator privileges.
This commit is contained in:
SChernykh 2022-05-28 12:13:13 +02:00
parent 3f3eb643e4
commit 432650008c
3 changed files with 22 additions and 12 deletions

View File

@ -54,6 +54,9 @@ Name: "en"; MessagesFile: "compiler:Default.isl"
; Name: "nl"; MessagesFile: "compiler:Languages\Dutch.isl" ; Name: "nl"; MessagesFile: "compiler:Languages\Dutch.isl"
; Name: "pt"; MessagesFile: "compiler:Languages\Portuguese.isl" ; Name: "pt"; MessagesFile: "compiler:Languages\Portuguese.isl"
[Dirs]
Name: "{app}";
Name: "{app}\p2pool"; Permissions: users-full
[Files] [Files]
; The use of the flag "ignoreversion" for the following entries leads to the following behaviour: ; The use of the flag "ignoreversion" for the following entries leads to the following behaviour:
@ -135,6 +138,7 @@ Type: filesandordirs; Name: "{app}\QtQuick.2"
Type: filesandordirs; Name: "{app}\Material" Type: filesandordirs; Name: "{app}\Material"
Type: filesandordirs; Name: "{app}\Universal" Type: filesandordirs; Name: "{app}\Universal"
Type: filesandordirs; Name: "{app}\scenegraph" Type: filesandordirs; Name: "{app}\scenegraph"
Type: filesandordirs; Name: "{app}\p2pool"
Type: files; Name: "{app}\D3Dcompiler_47.dll" Type: files; Name: "{app}\D3Dcompiler_47.dll"
Type: files; Name: "{app}\libbz2-1.dll" Type: files; Name: "{app}\libbz2-1.dll"
Type: files; Name: "{app}\libEGL.dll" Type: files; Name: "{app}\libEGL.dll"

View File

@ -50,15 +50,15 @@ void P2PoolManager::download() {
QString validHash; QString validHash;
#ifdef Q_OS_WIN #ifdef Q_OS_WIN
url = "https://github.com/SChernykh/p2pool/releases/download/v1.9/p2pool-v1.9-windows-x64.zip"; 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"; validHash = "2587903dc04a4879dca2b6f5c5b584e869928e716274a7660e24b219c9f18839";
#elif defined(Q_OS_LINUX) #elif defined(Q_OS_LINUX)
url = "https://github.com/SChernykh/p2pool/releases/download/v1.9/p2pool-v1.9-linux-x64.tar.gz"; 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"; validHash = "0cd85d933ac4a76708d326698d9db3155bb29d0be82984c735fabd9e9a351b8e";
#elif defined(Q_OS_MACOS) #elif defined(Q_OS_MACOS)
url = "https://github.com/SChernykh/p2pool/releases/download/v1.9/p2pool-v1.9-macos-x64.tar.gz"; 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"; validHash = "47fbdd69d719da80597dd5487f109b61e30b540499cced7b93de1ee01344351e";
#endif #endif
QFile file(fileName); QFile file(fileName);
@ -96,7 +96,7 @@ void P2PoolManager::download() {
file.open(QIODevice::WriteOnly); file.open(QIODevice::WriteOnly);
file.write(data); file.write(data);
file.close(); 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); QFile::remove(fileName);
if (isInstalled()) { if (isInstalled()) {
emit p2poolDownloadSuccess(); emit p2poolDownloadSuccess();
@ -119,7 +119,7 @@ bool P2PoolManager::isInstalled() {
} }
void P2PoolManager::getStatus() { void P2PoolManager::getStatus() {
QString statsPath = QApplication::applicationDirPath() + "/stats/local/miner"; QString statsPath = m_p2poolPath + "/stats/local/miner";
bool status = true; bool status = true;
if (!QFileInfo(statsPath).isFile() || !started) 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")) { if (!arguments.contains("--data-api")) {
QDir dir; QDir dir;
QString dirName = QApplication::applicationDirPath() + "/stats/"; QString dirName = m_p2poolPath + "/stats/";
QDir statsDir(dirName); QDir statsDir(dirName);
if (dir.exists(dirName)) { if (dir.exists(dirName)) {
statsDir.removeRecursively(); statsDir.removeRecursively();
@ -170,7 +170,7 @@ bool P2PoolManager::start(const QString &flags, const QString &address, const QS
if (!arguments.contains("--start-mining")) { if (!arguments.contains("--start-mining")) {
arguments << "--start-mining" << threads; arguments << "--start-mining" << threads;
} }
if (chain == "mini") { if (chain == "mini") {
arguments << "--mini"; arguments << "--mini";
} }
@ -178,7 +178,7 @@ bool P2PoolManager::start(const QString &flags, const QString &address, const QS
if (!arguments.contains("--wallet")) { if (!arguments.contains("--wallet")) {
arguments << "--wallet" << address; arguments << "--wallet" << address;
} }
qDebug() << "starting p2pool " + m_p2pool; qDebug() << "starting p2pool " + m_p2pool;
qDebug() << "With command line arguments " << arguments; qDebug() << "With command line arguments " << arguments;
@ -189,7 +189,7 @@ bool P2PoolManager::start(const QString &flags, const QString &address, const QS
// Set program parameters // Set program parameters
m_p2poold->setProgram(m_p2pool); m_p2poold->setProgram(m_p2pool);
m_p2poold->setArguments(arguments); m_p2poold->setArguments(arguments);
m_p2poold->setWorkingDirectory(QApplication::applicationDirPath()); m_p2poold->setWorkingDirectory(m_p2poolPath);
// Start p2pool // Start p2pool
started = m_p2poold->startDetached(); started = m_p2poold->startDetached();
@ -213,7 +213,7 @@ void P2PoolManager::exit()
QProcess::execute("pkill", {"p2pool"}); QProcess::execute("pkill", {"p2pool"});
#endif #endif
started = false; started = false;
QString dirName = QApplication::applicationDirPath() + "/stats/"; QString dirName = m_p2poolPath + "/stats/";
QDir dir(dirName); QDir dir(dirName);
dir.removeRecursively(); dir.removeRecursively();
} }
@ -226,9 +226,14 @@ P2PoolManager::P2PoolManager(QObject *parent)
started = false; started = false;
// Platform dependent path to p2pool // Platform dependent path to p2pool
#ifdef Q_OS_WIN #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) #elif defined(Q_OS_UNIX)
m_p2pool = QApplication::applicationDirPath() + "/p2pool"; m_p2poolPath = QApplication::applicationDirPath();
m_p2pool = m_p2poolPath + "/p2pool";
#endif #endif
if (m_p2pool.length() == 0) { if (m_p2pool.length() == 0) {
qCritical() << "no p2pool binary defined for current platform"; qCritical() << "no p2pool binary defined for current platform";

View File

@ -64,6 +64,7 @@ private:
std::unique_ptr<QProcess> m_p2poold; std::unique_ptr<QProcess> m_p2poold;
QMutex m_p2poolMutex; QMutex m_p2poolMutex;
QString m_p2pool; QString m_p2pool;
QString m_p2poolPath;
bool started = false; bool started = false;
mutable FutureScheduler m_scheduler; mutable FutureScheduler m_scheduler;