Skip to content
This repository was archived by the owner on Apr 24, 2022. It is now read-only.

Commit 528e7b8

Browse files
committedMay 25, 2018
Stratum nicehash. Avoid recalculating target with every job.
nicehash will periodically adjust difficulty, sending it as a float value to be converted to 32 byte target. There is no need to do the conversion with every job.
1 parent 3e1aedd commit 528e7b8

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed
 

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,6 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/).
66
## Unreleased
77
### Fixed
88
- Reconnecting with mining pool improved [[#1135](https://github.com/ethereum-mining/ethminer/pull/1135)].
9+
- Stratum nicehash. Avoid recalculating target with every job [[#1156](https://github.com/ethereum-mining/ethminer/pull/1156)].
910
### Removed
1011
- Disabled Debug configuration for Visual Studio [[#69](https://github.com/ethereum-mining/ethminer/issues/69)] [[#1131](https://github.com/ethereum-mining/ethminer/pull/1131)].

‎libpoolprotocols/stratum/EthStratumClient.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,6 @@ void EthStratumClient::processReponse(Json::Value& responseObject)
792792

793793
cnote << "Subscribed to stratum server";
794794

795-
m_nextWorkDifficulty = 1;
796-
797795
if (!jResult.empty() && jResult.isArray()) {
798796
std::string enonce = jResult.get((Json::Value::ArrayIndex)1, "").asString();
799797
processExtranonce(enonce);
@@ -982,8 +980,7 @@ void EthStratumClient::processReponse(Json::Value& responseObject)
982980
m_current.epoch = ethash::find_epoch_number(
983981
ethash::hash256_from_bytes(h256{sSeedHash}.data()));
984982
m_current.header = h256(sHeaderHash);
985-
m_current.boundary = h256();
986-
diffToTarget((uint32_t*)m_current.boundary.data(), m_nextWorkDifficulty);
983+
m_current.boundary = m_nextWorkBoundary;
987984
m_current.startNonce = bswap(*((uint64_t*)m_extraNonce.data()));
988985
m_current.exSizeBits = m_extraNonceHexSize * 4;
989986
m_current.job_len = job.size();
@@ -1035,9 +1032,10 @@ void EthStratumClient::processReponse(Json::Value& responseObject)
10351032
jPrm = responseObject.get("params", Json::Value::null);
10361033
if (jPrm.isArray())
10371034
{
1038-
m_nextWorkDifficulty = jPrm.get((Json::Value::ArrayIndex)0, 1).asDouble();
1039-
if (m_nextWorkDifficulty <= 0.0001) m_nextWorkDifficulty = 0.0001;
1040-
cnote << "Difficulty set to" << m_nextWorkDifficulty;
1035+
double nextWorkDifficulty = jPrm.get((Json::Value::ArrayIndex)0, 1).asDouble();
1036+
if (nextWorkDifficulty <= 0.0001) nextWorkDifficulty = 0.0001;
1037+
diffToTarget((uint32_t*)m_nextWorkBoundary.data(), nextWorkDifficulty);
1038+
cnote << "Difficulty set to" << nextWorkDifficulty;
10411039
}
10421040
}
10431041
else if (_method == "mining.set_extranonce" && m_conn.Version() == EthStratumClient::ETHEREUMSTRATUM)
@@ -1307,4 +1305,5 @@ void EthStratumClient::onSSLShutdownCompleted(const boost::system::error_code& e
13071305
// cnote << "onSSLShutdownCompleted Error code is : " << ec.message();
13081306
m_io_service.post(m_io_strand.wrap(boost::bind(&EthStratumClient::disconnect_finalize, this)));
13091307

1310-
}
1308+
}
1309+

‎libpoolprotocols/stratum/EthStratumClient.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ class EthStratumClient : public PoolClient
108108
string m_email;
109109
string m_rate;
110110

111-
double m_nextWorkDifficulty;
111+
h256 m_nextWorkBoundary;
112112

113113
h64 m_extraNonce;
114114
int m_extraNonceHexSize;

0 commit comments

Comments
 (0)