Skip to content

Commit

Permalink
Add --exit-new-epoch option (PR ethereum-mining#2367)
Browse files Browse the repository at this point in the history
RTX 3000 must apply oc after DAG generation.
This option allows easier scripting because now scripts can know there is new epoch when ethminer exit.
  • Loading branch information
Phil Davidov committed Nov 15, 2021
1 parent ec98771 commit 590b629
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
5 changes: 5 additions & 0 deletions ethminer/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ using namespace dev::eth;
// Global vars
bool g_running = false;
bool g_exitOnError = false; // Whether or not ethminer should exit on mining threads errors
bool g_exitOnNewEpoch = false; // Exit on new epoch

condition_variable g_shouldstop;
boost::asio::io_service g_io_service; // The IO service itself
Expand Down Expand Up @@ -272,6 +273,8 @@ class MinerCLI

app.add_flag("--exit", g_exitOnError, "");

app.add_flag("--exit-new-epoch", g_exitOnNewEpoch, "");

vector<string> pools;
app.add_option("-P,--pool", pools, "");

Expand Down Expand Up @@ -1009,6 +1012,8 @@ class MinerCLI
<< " 2 As 1 plus monitor power drain" << endl
<< " --exit FLAG Stop ethminer whenever an error is encountered"
<< endl
<< " --exit-new-epoch FLAG Stop ethminer when epoch changes"
<< endl
<< " --ergodicity INT[0 .. 2] Default = 0" << endl
<< " Sets how ethminer chooses the nonces segments to"
<< endl
Expand Down
9 changes: 8 additions & 1 deletion libethash-cuda/CUDAMiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,9 @@ bool CUDAMiner::initEpoch_internal()
<< m_deviceDescriptor.uniqueId;
cudalog << "Mining suspended ...";
pause(MinerPauseEnum::PauseDueToInitEpochError);
retVar = true;
string _what = "GPU error when generating DAG!";
throw std::runtime_error(_what);
retVar = false;
}

return retVar;
Expand Down Expand Up @@ -214,6 +216,11 @@ void CUDAMiner::workLoop()
// Epoch change ?
if (current.epoch != w.epoch)
{
if (current.epoch != -1 && g_exitOnNewEpoch)
{
std::cerr << "Epoch change, miner exit!" << std::endl;
raise(SIGTERM);
}
if (!initEpoch())
break; // This will simply exit the thread

Expand Down
2 changes: 2 additions & 0 deletions libethash-cuda/CUDAMiner.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ along with ethminer. If not, see <http://www.gnu.org/licenses/>.

#include <functional>

extern bool g_exitOnNewEpoch;

namespace dev
{
namespace eth
Expand Down

0 comments on commit 590b629

Please sign in to comment.