Skip to content

Commit 5f211ef

Browse files
don't submit share if we don't have a valid stratum connection
1 parent 41281b2 commit 5f211ef

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# cmake global
22
cmake_minimum_required(VERSION 2.8.12)
33

4-
set(PROJECT_VERSION "2.1.20")
4+
set(PROJECT_VERSION "2.1.21")
55
if (${CMAKE_VERSION} VERSION_GREATER 3.0)
66
cmake_policy(SET CMP0042 OLD) # fix MACOSX_RPATH
77
cmake_policy(SET CMP0048 NEW) # allow VERSION argument in project()

libstratum/EthStratumClient.cpp

+7-1
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ void EthStratumClient::disconnect()
143143
if (m_verbose)
144144
LogS << "Disconnecting from stratum server";
145145
m_connected = false;
146+
146147
m_authorized = false;
147148
m_running = false;
148149
m_socket.close();
@@ -301,6 +302,11 @@ void EthStratumClient::submitWork(h256 _nonce, bytes _hash, bytes _challenge, ui
301302

302303
Json::Value msg;
303304

305+
if (!isConnected()) {
306+
LogB << "Can't submit share: no stratum connection, or not subscribed";
307+
return;
308+
}
309+
304310
msg["id"] = 4;
305311
msg["method"] = "mining.submit";
306312
msg["params"].append("0x" + _nonce.hex());
@@ -339,7 +345,7 @@ bool EthStratumClient::isRunning()
339345
return m_running;
340346
}
341347

342-
bool EthStratumClient::isConnected()
348+
bool EthStratumClient::isConnected()
343349
{
344350
return m_connected && m_authorized;
345351
}

libstratum/EthStratumClient.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ class EthStratumClient
6767
void readResponse(const boost::system::error_code& ec, std::size_t bytes_transferred);
6868
void processReponse(Json::Value& responseObject);
6969
void writeStratum(Json::Value _json);
70-
void setWork(Json::Value params);
7170
void work_timeout_handler(const boost::system::error_code& ec);
7271
string streamBufToStr(boost::asio::streambuf &buff);
7372
void logJson(Json::Value _json);
@@ -78,7 +77,7 @@ class EthStratumClient
7877
string m_password;
7978

8079
bool m_authorized; // we're subscribed to the pool
81-
bool m_connected; // this refers to a TCP connection
80+
bool m_connected; // this refers to a TCP connection
8281
bool m_running; // the Boost::Asio worker thread is running & listening
8382

8483
int m_retries = 0;

0 commit comments

Comments
 (0)