|
@ -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) { |
|
|