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

Commit

Permalink
Bug fixes & improvements
Browse files Browse the repository at this point in the history
- report DAG generation when preparing to mine on stratum
- diff 0 bug fix
  • Loading branch information
nicehashdev committed Jun 7, 2016
1 parent 8cb2bdd commit 9cb223e
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 25 deletions.
32 changes: 13 additions & 19 deletions ethminer/MinerAux.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,12 +96,6 @@ struct MiningChannel: public LogChannel
};
#define minelog clog(MiningChannel)

struct ReportStruct
{
double speed;
unsigned int DAGprogress;
};

class MinerCLI
{
public:
Expand Down Expand Up @@ -1057,7 +1051,7 @@ class MinerCLI
m_farmRecheckPeriod = m_defaultStratumFarmRecheckPeriod;

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

#define WORKINGPROGRESS_BACKLOG_SIZE 32
#define REPORT_DELAY 4
//#define REPORT_DELAY 4
WorkingProgress wplist[WORKINGPROGRESS_BACKLOG_SIZE];
int wplist_index = 0;
bool first = false;
//int wplist_filled = 0;

while (client.isRunning())
{
Expand All @@ -1103,23 +1096,24 @@ class MinerCLI
mp.hashes += wplist[i].hashes;
mp.ms += wplist[i].ms;
}

if (wplist_index % REPORT_DELAY == 0)
{
ReportStruct rs;
rs.speed = 0;
if (mp.ms > 0)
rs.speed = (double)mp.hashes / (mp.ms * 1000);
rs.DAGprogress = 100;
m_speedReportSocket->send_to(boost::asio::buffer((void*)&rs, sizeof(ReportStruct)), endpoint);
}
}

f.resetMiningProgress();
if (client.isConnected())
{
if (client.current())
{
minelog << "Mining on PoWhash" << "#" + (client.currentHeaderHash().hex().substr(0, 8)) << ": " << mp << f.getSolutionStats();
//if (wplist_index % REPORT_DELAY == 0)
//{
ReportStruct rs;
rs.speed = 0;
if (mp.ms > 0)
rs.speed = (double)mp.hashes / (mp.ms * 1000);
rs.DAGprogress = 100;
m_speedReportSocket->send_to(boost::asio::buffer((void*)&rs, sizeof(ReportStruct)), endpoint);
//}
}
else if (client.waitState() == MINER_WAIT_STATE_WORK)
minelog << "Waiting for work package...";
}
Expand Down
2 changes: 1 addition & 1 deletion libethcore/EthashCUDAMiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ void EthashCUDAMiner::workLoop()
uint64_t startn = w.startNonce | ((uint64_t)index() << (64 - 4 - w.exSizeBits)); // this can support up to 16 devices
uint64_t swapped = ethash_swap_u64(startn);
Nonce startN((byte const*)&swapped, h64::ConstructFromPointerType::ConstructFromPointer);
cnote << "starting nonce is " << startN.hex();
//cnote << "starting nonce is " << startN.hex();
m_miner->search(w.headerHash.data(), upper64OfBoundary, *m_hook, startn);
}
catch (std::runtime_error const& _e)
Expand Down
2 changes: 1 addition & 1 deletion libethcore/EthashGPUMiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ void EthashGPUMiner::workLoop()
uint64_t startn = w.startNonce | ((uint64_t)index() << (64 - 4 - w.exSizeBits)); // this can support up to 16 devices
uint64_t swapped = ethash_swap_u64(startn);
Nonce startN((byte const*)&swapped, h64::ConstructFromPointerType::ConstructFromPointer);
cnote << "starting nonce is " << startN.hex();
//cnote << "starting nonce is " << startN.hex();
m_miner->search(w.headerHash.data(), upper64OfBoundary, *m_hook, startn);
}
catch (cl::Error const& _e)
Expand Down
19 changes: 16 additions & 3 deletions libstratum/EthStratumClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
using boost::asio::ip::tcp;


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)
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,
boost::asio::ip::udp::socket* speedReportSocket, uint16_t speedReportPort)
: m_socket(m_io_service)
{
m_minerType = m;
Expand All @@ -23,6 +24,9 @@ EthStratumClient::EthStratumClient(GenericFarm<EthashProofOfWork> * f, MinerType
m_maxRetries = retries;
m_worktimeout = worktimeout;

m_speedReportSocket = speedReportSocket;
m_speedReportPort = speedReportPort;

p_farm = f;
p_worktimer = nullptr;
connect();
Expand Down Expand Up @@ -354,7 +358,15 @@ void EthStratumClient::processReponse(Json::Value& responseObject)
{
cnote << "Grabbing DAG for" << seedHash;
}
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; })))
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...";
ReportStruct rs;
rs.DAGprogress = _pc;
rs.speed = 0;
boost::asio::ip::udp::endpoint endpoint(boost::asio::ip::address::from_string("127.0.0.1"), m_speedReportPort);
m_speedReportSocket->send_to(boost::asio::buffer((void*)&rs, (size_t)sizeof(ReportStruct)), endpoint);
return 0;
})))
{
BOOST_THROW_EXCEPTION(DAGCreationFailure());
}
Expand Down Expand Up @@ -398,6 +410,7 @@ void EthStratumClient::processReponse(Json::Value& responseObject)
if (params.isArray())
{
m_nextWorkDifficulty = params.get((Json::Value::ArrayIndex)0, 1).asDouble();
if (m_nextWorkDifficulty <= 0.0001) m_nextWorkDifficulty = 0.0001;
cnote << "Difficulty set to " << m_nextWorkDifficulty;
}
}
Expand Down Expand Up @@ -436,7 +449,7 @@ bool EthStratumClient::submit(EthashProofOfWork::Solution solution) {

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

if (EthashAux::eval(tempWork.seedHash, tempWork.headerHash, solution.nonce).value < tempWork.boundary)
{
Expand Down
11 changes: 10 additions & 1 deletion libstratum/EthStratumClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@ typedef struct {
string pass;
} cred_t;

struct ReportStruct
{
double speed;
unsigned int DAGprogress;
};

class EthStratumClient
{
public:
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);
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,
boost::asio::ip::udp::socket* speedReportSocket, uint16_t speedReportPort);
~EthStratumClient();

void setFailover(string const & host, string const & port);
Expand Down Expand Up @@ -98,4 +105,6 @@ class EthStratumClient
double m_nextWorkDifficulty = 1;
h64 m_extraNonce;
int m_extraNonceHexSize;
boost::asio::ip::udp::socket* m_speedReportSocket;
uint16_t m_speedReportPort;
};

0 comments on commit 9cb223e

Please sign in to comment.