Browse Source

borked responses..

cl-refactor
Jan Willem Penterman 9 years ago
parent
commit
b758820080
  1. 9
      ethminer/MinerAux.h
  2. 46
      libstratum/EthStratumClient.cpp
  3. 5
      libstratum/EthStratumClient.h

9
ethminer/MinerAux.h

@ -886,22 +886,25 @@ private:
EthStratumClient client(&f, host, port, user, pass); EthStratumClient client(&f, host, port, user, pass);
f.setSealers(sealers); f.setSealers(sealers);
/*
if (_m == MinerType::CPU) if (_m == MinerType::CPU)
f.start("cpu"); f.start("cpu");
else if (_m == MinerType::CL) else if (_m == MinerType::CL)
f.start("opencl"); f.start("opencl");
else if (_m == MinerType::CUDA) else if (_m == MinerType::CUDA)
f.start("cuda"); f.start("cuda");
*/
bool completed = false; bool completed = false;
EthashProofOfWork::Solution solution; EthashProofOfWork::Solution solution;
/*
f.onSolutionFound([&](EthashProofOfWork::Solution sol) f.onSolutionFound([&](EthashProofOfWork::Solution sol)
{ {
solution = sol; solution = sol;
minelog << "Solution!"; minelog << "Solution!";
return client.submit(solution); client.submit(solution);
return false;
}); });
*/
while (client.isRunning()) while (client.isRunning())
{ {
auto mp = f.miningProgress(); auto mp = f.miningProgress();

46
libstratum/EthStratumClient.cpp

@ -103,13 +103,39 @@ void EthStratumClient::readResponse(const boost::system::error_code& ec, std::si
std::istream is(&m_responseBuffer); std::istream is(&m_responseBuffer);
std::string response; std::string response;
getline(is, response); getline(is, response);
//cnote << response; cnote << response;
if (response.back() != '}') {
m_response = response;
}
if (response.front() != '{') {
response = m_response + response;
}
Json::Value responseObject; Json::Value responseObject;
Json::Reader reader; Json::Reader reader;
if (reader.parse(response.c_str(), responseObject)) if (reader.parse(response.c_str(), responseObject))
{ {
if (responseObject.isMember("id")) { processReponse(responseObject);
m_response = response;
}
else
{
cwarn << "Parse response failed: " << reader.getFormattedErrorMessages();
}
}
else
{
cwarn << "Read response failed: " << ec.message();
}
async_read_until(m_socket, m_responseBuffer, "\n",
boost::bind(&EthStratumClient::readResponse, this,
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
void EthStratumClient::processReponse(Json::Value& responseObject)
{
Json::Value error = responseObject.get("error", NULL); Json::Value error = responseObject.get("error", NULL);
if (error.isArray()) if (error.isArray())
{ {
@ -140,7 +166,7 @@ void EthStratumClient::readResponse(const boost::system::error_code& ec, std::si
cnote << "Authorized worker " << m_user; cnote << "Authorized worker " << m_user;
break; break;
case 4: case 4:
cnote << response; cnote << m_response;
default: default:
string method = responseObject.get("method", "").asString(); string method = responseObject.get("method", "").asString();
if (method == "mining.notify") if (method == "mining.notify")
@ -194,20 +220,6 @@ void EthStratumClient::readResponse(const boost::system::error_code& ec, std::si
} }
break; break;
} }
}
async_read_until(m_socket, m_responseBuffer, "\n",
boost::bind(&EthStratumClient::readResponse, this,
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
}
else
{
cwarn << "Parse response failed: " << reader.getFormattedErrorMessages();
}
}
else
{
cwarn << "Read response failed: " << ec.message();
}
} }
bool EthStratumClient::submit(EthashProofOfWork::Solution solution) { bool EthStratumClient::submit(EthashProofOfWork::Solution solution) {

5
libstratum/EthStratumClient.h

@ -34,8 +34,7 @@ private:
void handleResponse(const boost::system::error_code& ec); void handleResponse(const boost::system::error_code& ec);
void readResponse(const boost::system::error_code& ec, std::size_t bytes_transferred); void readResponse(const boost::system::error_code& ec, std::size_t bytes_transferred);
void processReponse(Json::Value& responseObject);
string m_host; string m_host;
string m_port; string m_port;
@ -45,6 +44,8 @@ private:
bool m_running; bool m_running;
bool m_precompute; bool m_precompute;
string m_response;
GenericFarm<EthashProofOfWork> * p_farm; GenericFarm<EthashProofOfWork> * p_farm;
EthashProofOfWork::WorkPackage m_current; EthashProofOfWork::WorkPackage m_current;
string m_job; string m_job;

Loading…
Cancel
Save