Skip to content

Commit

Permalink
don't submit share if we don't have a valid stratum connection
Browse files Browse the repository at this point in the history
  • Loading branch information
mining-visualizer committed Sep 15, 2019
1 parent 41281b2 commit 5f211ef
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# cmake global
cmake_minimum_required(VERSION 2.8.12)

set(PROJECT_VERSION "2.1.20")
set(PROJECT_VERSION "2.1.21")
if (${CMAKE_VERSION} VERSION_GREATER 3.0)
cmake_policy(SET CMP0042 OLD) # fix MACOSX_RPATH
cmake_policy(SET CMP0048 NEW) # allow VERSION argument in project()
Expand Down
8 changes: 7 additions & 1 deletion libstratum/EthStratumClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ void EthStratumClient::disconnect()
if (m_verbose)
LogS << "Disconnecting from stratum server";
m_connected = false;

m_authorized = false;
m_running = false;
m_socket.close();
Expand Down Expand Up @@ -301,6 +302,11 @@ void EthStratumClient::submitWork(h256 _nonce, bytes _hash, bytes _challenge, ui

Json::Value msg;

if (!isConnected()) {
LogB << "Can't submit share: no stratum connection, or not subscribed";
return;
}

msg["id"] = 4;
msg["method"] = "mining.submit";
msg["params"].append("0x" + _nonce.hex());
Expand Down Expand Up @@ -339,7 +345,7 @@ bool EthStratumClient::isRunning()
return m_running;
}

bool EthStratumClient::isConnected()
bool EthStratumClient::isConnected()
{
return m_connected && m_authorized;
}
Expand Down
3 changes: 1 addition & 2 deletions libstratum/EthStratumClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ class EthStratumClient
void readResponse(const boost::system::error_code& ec, std::size_t bytes_transferred);
void processReponse(Json::Value& responseObject);
void writeStratum(Json::Value _json);
void setWork(Json::Value params);
void work_timeout_handler(const boost::system::error_code& ec);
string streamBufToStr(boost::asio::streambuf &buff);
void logJson(Json::Value _json);
Expand All @@ -78,7 +77,7 @@ class EthStratumClient
string m_password;

bool m_authorized; // we're subscribed to the pool
bool m_connected; // this refers to a TCP connection
bool m_connected; // this refers to a TCP connection
bool m_running; // the Boost::Asio worker thread is running & listening

int m_retries = 0;
Expand Down

0 comments on commit 5f211ef

Please sign in to comment.