Skip to content
This repository was archived by the owner on Oct 21, 2019. It is now read-only.

Commit 9cb223e

Browse files
author
nicehashdev
committed
Bug fixes & improvements
- report DAG generation when preparing to mine on stratum - diff 0 bug fix
1 parent 8cb2bdd commit 9cb223e

5 files changed

Lines changed: 41 additions & 25 deletions

File tree

ethminer/MinerAux.h

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,6 @@ struct MiningChannel: public LogChannel
9696
};
9797
#define minelog clog(MiningChannel)
9898

99-
struct ReportStruct
100-
{
101-
double speed;
102-
unsigned int DAGprogress;
103-
};
104-
10599
class MinerCLI
106100
{
107101
public:
@@ -1057,7 +1051,7 @@ class MinerCLI
10571051
m_farmRecheckPeriod = m_defaultStratumFarmRecheckPeriod;
10581052

10591053
GenericFarm<EthashProofOfWork> f;
1060-
EthStratumClient client(&f, m_minerType, m_farmURL, m_port, m_user, m_pass, m_maxFarmRetries, m_worktimeout, m_precompute);
1054+
EthStratumClient client(&f, m_minerType, m_farmURL, m_port, m_user, m_pass, m_maxFarmRetries, m_worktimeout, m_precompute, m_speedReportSocket, m_speedReportPort);
10611055
if (m_farmFailOverURL != "")
10621056
{
10631057
if (m_fuser != "")
@@ -1080,11 +1074,10 @@ class MinerCLI
10801074
boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string("127.0.0.1"), m_speedReportPort);
10811075

10821076
#define WORKINGPROGRESS_BACKLOG_SIZE 32
1083-
#define REPORT_DELAY 4
1077+
//#define REPORT_DELAY 4
10841078
WorkingProgress wplist[WORKINGPROGRESS_BACKLOG_SIZE];
10851079
int wplist_index = 0;
10861080
bool first = false;
1087-
//int wplist_filled = 0;
10881081

10891082
while (client.isRunning())
10901083
{
@@ -1103,23 +1096,24 @@ class MinerCLI
11031096
mp.hashes += wplist[i].hashes;
11041097
mp.ms += wplist[i].ms;
11051098
}
1106-
1107-
if (wplist_index % REPORT_DELAY == 0)
1108-
{
1109-
ReportStruct rs;
1110-
rs.speed = 0;
1111-
if (mp.ms > 0)
1112-
rs.speed = (double)mp.hashes / (mp.ms * 1000);
1113-
rs.DAGprogress = 100;
1114-
m_speedReportSocket->send_to(boost::asio::buffer((void*)&rs, sizeof(ReportStruct)), endpoint);
1115-
}
11161099
}
11171100

11181101
f.resetMiningProgress();
11191102
if (client.isConnected())
11201103
{
11211104
if (client.current())
1105+
{
11221106
minelog << "Mining on PoWhash" << "#" + (client.currentHeaderHash().hex().substr(0, 8)) << ": " << mp << f.getSolutionStats();
1107+
//if (wplist_index % REPORT_DELAY == 0)
1108+
//{
1109+
ReportStruct rs;
1110+
rs.speed = 0;
1111+
if (mp.ms > 0)
1112+
rs.speed = (double)mp.hashes / (mp.ms * 1000);
1113+
rs.DAGprogress = 100;
1114+
m_speedReportSocket->send_to(boost::asio::buffer((void*)&rs, sizeof(ReportStruct)), endpoint);
1115+
//}
1116+
}
11231117
else if (client.waitState() == MINER_WAIT_STATE_WORK)
11241118
minelog << "Waiting for work package...";
11251119
}

libethcore/EthashCUDAMiner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ void EthashCUDAMiner::workLoop()
184184
uint64_t startn = w.startNonce | ((uint64_t)index() << (64 - 4 - w.exSizeBits)); // this can support up to 16 devices
185185
uint64_t swapped = ethash_swap_u64(startn);
186186
Nonce startN((byte const*)&swapped, h64::ConstructFromPointerType::ConstructFromPointer);
187-
cnote << "starting nonce is " << startN.hex();
187+
//cnote << "starting nonce is " << startN.hex();
188188
m_miner->search(w.headerHash.data(), upper64OfBoundary, *m_hook, startn);
189189
}
190190
catch (std::runtime_error const& _e)

libethcore/EthashGPUMiner.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ void EthashGPUMiner::workLoop()
173173
uint64_t startn = w.startNonce | ((uint64_t)index() << (64 - 4 - w.exSizeBits)); // this can support up to 16 devices
174174
uint64_t swapped = ethash_swap_u64(startn);
175175
Nonce startN((byte const*)&swapped, h64::ConstructFromPointerType::ConstructFromPointer);
176-
cnote << "starting nonce is " << startN.hex();
176+
//cnote << "starting nonce is " << startN.hex();
177177
m_miner->search(w.headerHash.data(), upper64OfBoundary, *m_hook, startn);
178178
}
179179
catch (cl::Error const& _e)

libstratum/EthStratumClient.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
using boost::asio::ip::tcp;
66

77

8-
EthStratumClient::EthStratumClient(GenericFarm<EthashProofOfWork> * f, MinerType m, string const & host, string const & port, string const & user, string const & pass, int const & retries, int const & worktimeout, bool const & precompute)
8+
EthStratumClient::EthStratumClient(GenericFarm<EthashProofOfWork> * f, MinerType m, string const & host, string const & port, string const & user, string const & pass, int const & retries, int const & worktimeout, bool const & precompute,
9+
boost::asio::ip::udp::socket* speedReportSocket, uint16_t speedReportPort)
910
: m_socket(m_io_service)
1011
{
1112
m_minerType = m;
@@ -23,6 +24,9 @@ EthStratumClient::EthStratumClient(GenericFarm<EthashProofOfWork> * f, MinerType
2324
m_maxRetries = retries;
2425
m_worktimeout = worktimeout;
2526

27+
m_speedReportSocket = speedReportSocket;
28+
m_speedReportPort = speedReportPort;
29+
2630
p_farm = f;
2731
p_worktimer = nullptr;
2832
connect();
@@ -354,7 +358,15 @@ void EthStratumClient::processReponse(Json::Value& responseObject)
354358
{
355359
cnote << "Grabbing DAG for" << seedHash;
356360
}
357-
if (!(dag = EthashAux::full(seedHash, true, [&](unsigned _pc){ m_waitState = _pc < 100 ? MINER_WAIT_STATE_DAG : MINER_WAIT_STATE_WORK; cnote << "Creating DAG. " << _pc << "% done..."; return 0; })))
361+
if (!(dag = EthashAux::full(seedHash, true, [&](unsigned _pc) {
362+
m_waitState = _pc < 100 ? MINER_WAIT_STATE_DAG : MINER_WAIT_STATE_WORK; cnote << "Creating DAG. " << _pc << "% done...";
363+
ReportStruct rs;
364+
rs.DAGprogress = _pc;
365+
rs.speed = 0;
366+
boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string("127.0.0.1"), m_speedReportPort);
367+
m_speedReportSocket->send_to(boost::asio::buffer((void*)&rs, (size_t)sizeof(ReportStruct)), endpoint);
368+
return 0;
369+
})))
358370
{
359371
BOOST_THROW_EXCEPTION(DAGCreationFailure());
360372
}
@@ -398,6 +410,7 @@ void EthStratumClient::processReponse(Json::Value& responseObject)
398410
if (params.isArray())
399411
{
400412
m_nextWorkDifficulty = params.get((Json::Value::ArrayIndex)0, 1).asDouble();
413+
if (m_nextWorkDifficulty <= 0.0001) m_nextWorkDifficulty = 0.0001;
401414
cnote << "Difficulty set to " << m_nextWorkDifficulty;
402415
}
403416
}
@@ -436,7 +449,7 @@ bool EthStratumClient::submit(EthashProofOfWork::Solution solution) {
436449

437450
cnote << "Solution found; Submitting to" << p_active->host << "...";
438451
string minernonce = solution.nonce.hex().substr(m_extraNonceHexSize, 16 - m_extraNonceHexSize);
439-
cnote << " Miner nonce:" << minernonce;
452+
//cnote << " Miner nonce:" << minernonce;
440453

441454
if (EthashAux::eval(tempWork.seedHash, tempWork.headerHash, solution.nonce).value < tempWork.boundary)
442455
{

libstratum/EthStratumClient.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,17 @@ typedef struct {
2424
string pass;
2525
} cred_t;
2626

27+
struct ReportStruct
28+
{
29+
double speed;
30+
unsigned int DAGprogress;
31+
};
32+
2733
class EthStratumClient
2834
{
2935
public:
30-
EthStratumClient(GenericFarm<EthashProofOfWork> * f, MinerType m, string const & host, string const & port, string const & user, string const & pass, int const & retries, int const & worktimeout, bool const & precompute);
36+
EthStratumClient(GenericFarm<EthashProofOfWork> * f, MinerType m, string const & host, string const & port, string const & user, string const & pass, int const & retries, int const & worktimeout, bool const & precompute,
37+
boost::asio::ip::udp::socket* speedReportSocket, uint16_t speedReportPort);
3138
~EthStratumClient();
3239

3340
void setFailover(string const & host, string const & port);
@@ -98,4 +105,6 @@ class EthStratumClient
98105
double m_nextWorkDifficulty = 1;
99106
h64 m_extraNonce;
100107
int m_extraNonceHexSize;
108+
boost::asio::ip::udp::socket* m_speedReportSocket;
109+
uint16_t m_speedReportPort;
101110
};

0 commit comments

Comments
 (0)