True, it isn't stable. I'm working on creating a timeout clientside. So if the miner is working on the same job for over, let's say 1.5 the blocktime, we can safely assume the connection is botched. Reconect and try again. I know it;s a band-aid for a problem I haven't been able to identify yet, but it's better than what we have now..
Hi!I think this hack will not work.
For me the problem appears on reconnetct after connection errors.
As I see the received data was corrupted.
I think this is a race condition problem.
You perform asynchronous reading (based on hooks) but your m_pending counter not protected by mutex/semaphore.
I tried perform fast fix: I remove all m_pending counter logic and readline() call from readResponse() and insert multiple readline() calls into processReponse().
For me it fixes this bug, but this is bull shit code only for test proof of concept.
I think the right desigion - it's to create a separate thread with infinite loop, which will read all responces.
Code:
void EthStratumClient::readline() {
//if (m_pending == 0) {
async_read_until(m_socket, m_responseBuffer, "\n",
boost::bind(&EthStratumClient::readResponse, this,
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
// m_pending++;
//}
}
...
void EthStratumClient::readResponse(const boost::system::error_code& ec, std::size_t bytes_transferred)
{
//m_pending = m_pending > 0 ? m_pending - 1 : 0;
if (!ec)
{
...
if (response.front() == '{' && response.back() == '}')
{...}
else
{...}
//readline();
}
else
{...}
}
void EthStratumClient::processReponse(Json::Value& responseObject)
{
...
switch (id)
{
...
case 2:
...
cnote << "Authorized worker " << m_user;
readline();//!!!
break;
...
default:
string method = responseObject.get("method", "").asString();
if (method == "mining.notify")
{
...
readline();//!!!
}
else if (method == "mining.set_difficulty")
{
readline();//!!!
}
...
}
}
That mostly worked for me. Fixed it so that I am at least getting some credit for my PoW. Now I have an issue when ethmine finds a solution and submits. [edit]Forgot to say that this is on Ubuntu 15.04 compiled from latest git source w/ maxvall's changes[/edit]
miner 17:44:23|ethminer Mining on PoWhash #8cfecaa1… : 17825792 H/s = 8912896 hashes / 0.5 s
ℹ 17:44:23|gpuminer0 Solution found; Submitting to coinotron.com ...
ℹ 17:44:23|gpuminer0 Nonce: 0x058b32e369abb660
ℹ 17:44:23|gpuminer0 Mixhash: 0xeabb595fadd73ad991bb0861cbc803173febbbcb606bda71e3b1dac88fa9e1e9
ℹ 17:44:23|gpuminer0 Header-hash: 0x8cfecaa177efd06de20a5dc5f4fd6bd1aa38d1efaad617befc02a82644cbb624
ℹ 17:44:23|gpuminer0 Seedhash: 0x63ca6f54b1af76dd4df3b908cee464ff1f212f08352cbe7eb4422806bb0c7885
ℹ 17:44:23|gpuminer0 Target: 0x0000000174d3b7ba75827af894e99022396f5d9dc97a49d1ab70bb2445b917fb
ℹ 17:44:23|gpuminer0 Ethash: 0x000000015494c14ea01fe142ad3e2b6e1ac3a9523f6ca0b8949ceac0a6661e1c
ℹ 17:44:23|ethminer B-) Submitted and accepted.
miner 17:44:23|ethminer Mining on PoWhash #8cfecaa1… : 17301504 H/s = 8650752 hashes / 0.5 s
miner 17:44:24|ethminer Mining on PoWhash #8cfecaa1… : 17825792 H/s = 8912896 hashes / 0.5 s
miner 17:44:24|ethminer Mining on PoWhash #8cfecaa1… : 17301504 H/s = 8650752 hashes / 0.5 s
miner 17:44:25|ethminer Mining on PoWhash #8cfecaa1… : 17825792 H/s = 8912896 hashes / 0.5 s
miner 17:44:25|ethminer Mining on PoWhash #8cfecaa1… : 17825792 H/s = 8912896 hashes / 0.5 s
miner 17:44:26|ethminer Mining on PoWhash #8cfecaa1… : 17301504 H/s = 8650752 hashes / 0.5 s
miner 17:44:26|ethminer Mining on PoWhash #8cfecaa1… : 17825792 H/s = 8912896 hashes / 0.5 s
miner 17:44:27|ethminer Mining on PoWhash #8cfecaa1… : 4718592 H/s = 2359296 hashes / 0.5 s
miner 17:44:27|ethminer Mining on PoWhash #8cfecaa1… : 12058624 H/s = 6029312 hashes / 0.5 s
miner 17:44:28|ethminer Mining on PoWhash #8cfecaa1… : 17825792 H/s = 8912896 hashes / 0.5 s
miner 17:44:28|ethminer Mining on PoWhash #8cfecaa1… : 17301504 H/s = 8650752 hashes / 0.5 s
✘ 17:44:29|ethminer Discarding incomplete response
miner 17:44:29|ethminer Mining on PoWhash #8cfecaa1… : 17301504 H/s = 8650752 hashes / 0.5 s