From f565e7b09a8a628f17b9efbb39e9323e77bc7446 Mon Sep 17 00:00:00 2001 From: Aiwe Date: Tue, 4 Jan 2022 16:57:00 +0200 Subject: [PATCH] Disable cores deal when mining is active to prevent misunderstanding how it works, other changes in miner --- src/Miner.cpp | 8 +++++--- src/gui/MiningFrame.cpp | 14 ++++++++++++++ src/gui/MiningFrame.h | 1 + src/gui/ui/miningframe.ui | 17 +++++++++++++++++ 4 files changed, 37 insertions(+), 3 deletions(-) diff --git a/src/Miner.cpp b/src/Miner.cpp index 9fcc8f1cf..d7cc93e51 100644 --- a/src/Miner.cpp +++ b/src/Miner.cpp @@ -230,7 +230,7 @@ namespace WalletGui double Miner::get_speed() { if(is_mining()) - return m_hash_rate; + return m_hash_rate.load(); else return 0; } @@ -239,8 +239,6 @@ namespace WalletGui void Miner::send_stop_signal() { m_stop_mining = true; - m_current_hash_rate = 0; - m_last_hash_rates.clear(); } //----------------------------------------------------------------------------------------------------- @@ -258,6 +256,10 @@ namespace WalletGui m_threads.clear(); + m_current_hash_rate = 0; + m_hash_rate = 0; + m_last_hash_rates.clear(); + m_logger(Logging::INFO) << "Mining stopped, " << m_threads.size() << " threads finished" ; Q_EMIT minerMessageSignal(QString("Mining stopped, %1 threads finished").arg(threadsCount)); diff --git a/src/gui/MiningFrame.cpp b/src/gui/MiningFrame.cpp index e411185ba..2a5e47b0d 100644 --- a/src/gui/MiningFrame.cpp +++ b/src/gui/MiningFrame.cpp @@ -7,6 +7,9 @@ #include #include #include +#include +#include +#include #include "MiningFrame.h" #include "MainWindow.h" @@ -178,6 +181,8 @@ void MiningFrame::startSolo() { m_ui->m_startSolo->setChecked(true); m_ui->m_startSolo->setEnabled(false); m_ui->m_stopSolo->setEnabled(true); + m_ui->m_cpuCoresSpin->setEnabled(false); + m_ui->m_cpuDial->setEnabled(false); m_solo_mining = true; } @@ -193,6 +198,8 @@ void MiningFrame::stopSolo() { m_ui->m_hashratelcdNumber->display(0.0); m_ui->m_startSolo->setEnabled(true); m_ui->m_stopSolo->setEnabled(false); + m_ui->m_cpuCoresSpin->setEnabled(true); + m_ui->m_cpuDial->setEnabled(true); m_solo_mining = false; } } @@ -259,4 +266,11 @@ void MiningFrame::updateMinerLog(const QString& _message) { sb->setValue(sb->maximum()); } +void MiningFrame::coreDealTurned(int _cores) { + qDebug() << "Cores " << _cores; + QTimer::singleShot(600, [this, _cores]() { + Settings::instance().setMiningThreads(_cores); + } ); +} + } diff --git a/src/gui/MiningFrame.h b/src/gui/MiningFrame.h index 5dbfab98b..b17159da1 100644 --- a/src/gui/MiningFrame.h +++ b/src/gui/MiningFrame.h @@ -64,6 +64,7 @@ class MiningFrame : public QFrame { Q_SLOT void updateBalance(quint64 _balance); Q_SLOT void updatePendingBalance(quint64 _balance); Q_SLOT void updateMinerLog(const QString& _message); + Q_SLOT void coreDealTurned(int _cores); }; } diff --git a/src/gui/ui/miningframe.ui b/src/gui/ui/miningframe.ui index 6f5bf4f13..63b3cf45a 100644 --- a/src/gui/ui/miningframe.ui +++ b/src/gui/ui/miningframe.ui @@ -310,6 +310,22 @@ + + m_cpuCoresSpin + valueChanged(int) + MiningFrame + coreDealTurned(int) + + + 501 + 86 + + + 379 + 266 + + + startStopClicked(QAbstractButton*) @@ -317,6 +333,7 @@ stakeAmountChanged(int) stakeTermChanged(int) stakeMixinChanged(int) + coreDealTurned(int)