mirror of
https://github.com/feather-wallet/feather.git
synced 2025-03-12 09:37:47 +00:00
Mining: allow configuring pools
This commit is contained in:
parent
31ceeb478f
commit
f15eab8c9d
5 changed files with 116 additions and 100 deletions
|
@ -51,6 +51,7 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
|
|||
// Mining
|
||||
{Config::xmrigPath,{QS("xmrigPath"), ""}},
|
||||
{Config::xmrigPool,{QS("xmrigPool"), "pool.xmr.pt:9000"}},
|
||||
{Config::pools,{QS("pools"), {}}},
|
||||
|
||||
// Settings
|
||||
{Config::preferredFiatCurrency,{QS("preferredFiatCurrency"), "USD"}},
|
||||
|
|
|
@ -55,6 +55,7 @@ public:
|
|||
// Mining
|
||||
xmrigPath,
|
||||
xmrigPool,
|
||||
pools,
|
||||
|
||||
// Settings
|
||||
preferredFiatCurrency,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
|
||||
#include <QDesktopServices>
|
||||
#include <QFileDialog>
|
||||
#include <QInputDialog>
|
||||
#include <QMessageBox>
|
||||
#include <QScrollBar>
|
||||
#include <QStandardItemModel>
|
||||
|
@ -69,15 +70,22 @@ XMRigWidget::XMRigWidget(QSharedPointer<AppContext> ctx, QWidget *parent)
|
|||
|
||||
// pools
|
||||
ui->poolFrame->show();
|
||||
ui->combo_pools->insertItems(0, m_pools);
|
||||
auto preferredPool = config()->get(Config::xmrigPool).toString();
|
||||
if (m_pools.contains(preferredPool))
|
||||
ui->combo_pools->setCurrentIndex(m_pools.indexOf(preferredPool));
|
||||
else {
|
||||
preferredPool = m_pools.at(0);
|
||||
config()->set(Config::xmrigPool, preferredPool);
|
||||
}
|
||||
connect(ui->combo_pools, QOverload<int>::of(&QComboBox::currentIndexChanged), this, &XMRigWidget::onPoolChanged);
|
||||
this->updatePools();
|
||||
connect(ui->combo_pools, &QComboBox::currentTextChanged, this, &XMRigWidget::onPoolChanged);
|
||||
|
||||
connect(ui->btn_poolConfig, &QPushButton::clicked, [this]{
|
||||
QStringList pools = config()->get(Config::pools).toStringList();
|
||||
bool ok;
|
||||
QString poolStr = QInputDialog::getMultiLineText(this, "Pool addresses", "Set pool addresses (one per line):", pools.join("\n"), &ok);
|
||||
if (!ok) {
|
||||
return;
|
||||
}
|
||||
QStringList newPools = poolStr.split("\n");
|
||||
newPools.removeAll("");
|
||||
newPools.removeDuplicates();
|
||||
config()->set(Config::pools, newPools);
|
||||
this->updatePools();
|
||||
});
|
||||
|
||||
// info
|
||||
ui->console->appendPlainText(QString("Detected %1 CPU threads.").arg(threads));
|
||||
|
@ -132,8 +140,10 @@ void XMRigWidget::onThreadsValueChanged(int threads) {
|
|||
ui->label_threads->setText(QString("CPU threads: %1").arg(m_threads));
|
||||
}
|
||||
|
||||
void XMRigWidget::onPoolChanged(int pos) {
|
||||
config()->set(Config::xmrigPool, m_pools.at(pos));
|
||||
void XMRigWidget::onPoolChanged(const QString &pool) {
|
||||
if (!pool.isEmpty()) {
|
||||
config()->set(Config::xmrigPool, pool);
|
||||
}
|
||||
}
|
||||
|
||||
void XMRigWidget::onBrowseClicked() {
|
||||
|
@ -279,6 +289,24 @@ void XMRigWidget::showContextMenu(const QPoint &pos) {
|
|||
m_contextMenu->exec(ui->tableView->viewport()->mapToGlobal(pos));
|
||||
}
|
||||
|
||||
void XMRigWidget::updatePools() {
|
||||
QStringList pools = config()->get(Config::pools).toStringList();
|
||||
if (pools.isEmpty()) {
|
||||
pools = m_defaultPools;
|
||||
config()->set(Config::pools, pools);
|
||||
}
|
||||
ui->combo_pools->clear();
|
||||
ui->combo_pools->insertItems(0, pools);
|
||||
|
||||
QString preferredPool = config()->get(Config::xmrigPool).toString();
|
||||
if (pools.contains(preferredPool)) {
|
||||
ui->combo_pools->setCurrentIndex(pools.indexOf(preferredPool));
|
||||
} else {
|
||||
preferredPool = pools.at(0);
|
||||
config()->set(Config::xmrigPool, preferredPool);
|
||||
}
|
||||
}
|
||||
|
||||
void XMRigWidget::onSoloChecked(int state) {
|
||||
if(state == 2) {
|
||||
ui->poolFrame->hide();
|
||||
|
|
|
@ -42,7 +42,7 @@ public slots:
|
|||
private slots:
|
||||
void onBrowseClicked();
|
||||
void onThreadsValueChanged(int date);
|
||||
void onPoolChanged(int pos);
|
||||
void onPoolChanged(const QString &pool);
|
||||
|
||||
signals:
|
||||
void miningStarted();
|
||||
|
@ -50,6 +50,7 @@ signals:
|
|||
|
||||
private:
|
||||
void showContextMenu(const QPoint &pos);
|
||||
void updatePools();
|
||||
|
||||
QScopedPointer<Ui::XMRigWidget> ui;
|
||||
QSharedPointer<AppContext> m_ctx;
|
||||
|
@ -60,7 +61,7 @@ private:
|
|||
bool m_isMining = false;
|
||||
int m_threads;
|
||||
QStringList m_urls;
|
||||
QStringList m_pools{"pool.xmr.pt:9000", "pool.supportxmr.com:9000", "mine.xmrpool.net:443", "xmrpool.eu:9999", "xmr-eu1.nanopool.org:14433", "pool.minexmr.com:6666", "us-west.minexmr.com:6666", "monerohash.com:9999", "cryptonote.social:5555", "cryptonote.social:5556"};
|
||||
QStringList m_defaultPools{"pool.xmr.pt:9000", "pool.supportxmr.com:9000", "mine.xmrpool.net:443", "xmrpool.eu:9999", "xmr-eu1.nanopool.org:14433", "pool.minexmr.com:6666", "us-west.minexmr.com:6666", "monerohash.com:9999", "cryptonote.social:5555", "cryptonote.social:5556"};
|
||||
};
|
||||
|
||||
#endif // FEATHER_XMRWIDGET_H
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
<property name="windowTitle">
|
||||
<string>Form</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
|
@ -26,12 +26,12 @@
|
|||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<item>
|
||||
<widget class="QTabWidget" name="tabWidget">
|
||||
<property name="currentIndex">
|
||||
<number>1</number>
|
||||
</property>
|
||||
<widget class="QWidget" name="tab">
|
||||
<widget class="QWidget" name="tabMining">
|
||||
<attribute name="title">
|
||||
<string>Mining</string>
|
||||
</attribute>
|
||||
|
@ -121,7 +121,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_3">
|
||||
<widget class="QWidget" name="tabSettings">
|
||||
<attribute name="title">
|
||||
<string>Settings</string>
|
||||
</attribute>
|
||||
|
@ -241,56 +241,52 @@
|
|||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_4">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_4">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Pool</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="combo_pools">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="text">
|
||||
<string>Pool</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QComboBox" name="combo_pools">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btn_poolConfig">
|
||||
<property name="text">
|
||||
<string>Configure</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_3">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>414</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -303,53 +299,42 @@
|
|||
<property name="frameShadow">
|
||||
<enum>QFrame::Plain</enum>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_5">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<property name="leftMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="topMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="rightMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<property name="bottomMargin">
|
||||
<number>0</number>
|
||||
</property>
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_8">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_8">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Node address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_solo">
|
||||
<property name="text">
|
||||
<string>127.0.0.1:18081</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>40</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<item>
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Node address</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QLineEdit" name="lineEdit_solo">
|
||||
<property name="text">
|
||||
<string>127.0.0.1:18081</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="horizontalSpacer_5">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Horizontal</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>173</width>
|
||||
<height>20</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
|
@ -464,12 +449,12 @@
|
|||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="tab_2">
|
||||
<widget class="QWidget" name="tabDownloads">
|
||||
<attribute name="title">
|
||||
<string>Downloads</string>
|
||||
</attribute>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<layout class="QVBoxLayout" name="verticalLayout_7">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_7">
|
||||
<item>
|
||||
<widget class="QLabel" name="label_latest_version">
|
||||
|
@ -493,7 +478,7 @@
|
|||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<item>
|
||||
<widget class="QTableView" name="tableView">
|
||||
<property name="contextMenuPolicy">
|
||||
<enum>Qt::CustomContextMenu</enum>
|
||||
|
|
Loading…
Reference in a new issue