-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Stratum nicehash. Avoid recalculating target with every job. #1156
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -792,8 +792,8 @@ void EthStratumClient::processReponse(Json::Value& responseObject) | |
|
||
cnote << "Subscribed to stratum server"; | ||
|
||
m_nextWorkDifficulty = 1; | ||
m_nextWorkBoundary = h256("0xffff000000000000000000000000000000000000000000000000000000000000"); | ||
|
||
if (!jResult.empty() && jResult.isArray()) { | ||
std::string enonce = jResult.get((Json::Value::ArrayIndex)1, "").asString(); | ||
processExtranonce(enonce); | ||
|
@@ -982,8 +982,7 @@ void EthStratumClient::processReponse(Json::Value& responseObject) | |
m_current.epoch = ethash::find_epoch_number( | ||
ethash::hash256_from_bytes(h256{sSeedHash}.data())); | ||
m_current.header = h256(sHeaderHash); | ||
m_current.boundary = h256(); | ||
diffToTarget((uint32_t*)m_current.boundary.data(), m_nextWorkDifficulty); | ||
m_current.boundary = m_nextWorkBoundary; | ||
m_current.startNonce = bswap(*((uint64_t*)m_extraNonce.data())); | ||
m_current.exSizeBits = m_extraNonceHexSize * 4; | ||
m_current.job_len = job.size(); | ||
|
@@ -1035,9 +1034,10 @@ void EthStratumClient::processReponse(Json::Value& responseObject) | |
jPrm = responseObject.get("params", Json::Value::null); | ||
if (jPrm.isArray()) | ||
{ | ||
m_nextWorkDifficulty = jPrm.get((Json::Value::ArrayIndex)0, 1).asDouble(); | ||
if (m_nextWorkDifficulty <= 0.0001) m_nextWorkDifficulty = 0.0001; | ||
cnote << "Difficulty set to" << m_nextWorkDifficulty; | ||
double nextWorkDifficulty = jPrm.get((Json::Value::ArrayIndex)0, 1).asDouble(); | ||
if (nextWorkDifficulty <= 0.0001) nextWorkDifficulty = 0.0001; | ||
diffToTarget((uint32_t*)m_nextWorkBoundary.data(), nextWorkDifficulty); | ||
cnote << "Difficulty set to" << nextWorkDifficulty; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do not know if this is the right place where to put it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Two different things.
It's all very confusing... there are many ways to express difficulty. 1 - as a fraction of the maximum target value. All are equivalent. This code displays in format 1. The pool manager uses format 4. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmmm ... think we should find a standard way to express diff. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I should point out that this update changes nothing in this respect. No log messages were changed or added by this modification. |
||
} | ||
} | ||
else if (_method == "mining.set_extranonce" && m_conn.Version() == EthStratumClient::ETHEREUMSTRATUM) | ||
|
@@ -1307,4 +1307,5 @@ void EthStratumClient::onSSLShutdownCompleted(const boost::system::error_code& e | |
// cnote << "onSSLShutdownCompleted Error code is : " << ec.message(); | ||
m_io_service.post(m_io_strand.wrap(boost::bind(&EthStratumClient::disconnect_finalize, this))); | ||
|
||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not all
f
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems to be the max target value used in all ethereum code. Not sure why it's not all F's.