NiceHash support

This commit is contained in:
fireice-uk
2017-02-07 22:54:59 +00:00
parent bdad7f5662
commit 2078969378
6 changed files with 39 additions and 7 deletions
+8
View File
@@ -69,6 +69,14 @@
*/
"use_slow_memory" : "warn",
/*
* NiceHash mode
* nicehash_nonce - Limit the noce to 3 bytes as required by nicehash. This cuts all the safety margins, and
* if a block isn't found within 30 minutes then you might run into nonce collisions. Number
* of threads in this mode is hard-limited to 32.
*/
"nicehash_nonce" : false,
/*
* pool_address - Pool address should be in the form "pool.supportxmr.com:3333". Only stratum pools are supported.
* wallet_address - Your wallet, or pool login.
+5 -2
View File
@@ -210,7 +210,9 @@ void executor::on_pool_have_job(size_t pool_id, pool_job& oPoolJob)
jpsock* pool = pick_pool_by_id(pool_id);
minethd::miner_work oWork(oPoolJob.sJobID, oPoolJob.bWorkBlob,
oPoolJob.iWorkLen, oPoolJob.iResumeCnt, oPoolJob.iTarget, pool_id);
oPoolJob.iWorkLen, oPoolJob.iResumeCnt, oPoolJob.iTarget,
(pool_id != dev_pool_id) ? jconf::inst()->NiceHashMode() : false,
pool_id);
minethd::switch_work(oWork);
@@ -328,7 +330,8 @@ void executor::on_switch_pool(size_t pool_id)
}
minethd::miner_work oWork(oPoolJob.sJobID, oPoolJob.bWorkBlob,
oPoolJob.iWorkLen, oPoolJob.iResumeCnt, oPoolJob.iTarget, pool_id);
oPoolJob.iWorkLen, oPoolJob.iResumeCnt, oPoolJob.iTarget,
jconf::inst()->NiceHashMode(), pool_id);
minethd::switch_work(oWork);
+7 -1
View File
@@ -37,7 +37,7 @@ using namespace rapidjson;
/*
* This enum needs to match index in oConfigValues, otherwise we will get a runtime error
*/
enum configEnum { iCpuThreadNum, aCpuThreadsConf, sUseSlowMem, sPoolAddr, sWalletAddr,
enum configEnum { iCpuThreadNum, aCpuThreadsConf, sUseSlowMem, bNiceHashMode, sPoolAddr, sWalletAddr,
sPoolPwd, iCallTimeout, iNetRetry, iVerboseLevel, iAutohashTime, iHttpdPort, bPreferIpv4 };
struct configVal {
@@ -51,6 +51,7 @@ configVal oConfigValues[] = {
{ iCpuThreadNum, "cpu_thread_num", kNumberType },
{ aCpuThreadsConf, "cpu_threads_conf", kArrayType },
{ sUseSlowMem, "use_slow_memory", kStringType },
{ bNiceHashMode, "nicehash_nonce", kTrueType },
{ sPoolAddr, "pool_address", kStringType },
{ sWalletAddr, "wallet_address", kStringType },
{ sPoolPwd, "pool_password", kStringType },
@@ -203,6 +204,11 @@ uint16_t jconf::GetHttpdPort()
return prv->configValues[iHttpdPort]->GetUint();
}
bool jconf::NiceHashMode()
{
return prv->configValues[bNiceHashMode]->GetBool();
}
bool jconf::check_cpu_features()
{
constexpr int AESNI_BIT = 1 << 25;
+2
View File
@@ -44,6 +44,8 @@ public:
uint16_t GetHttpdPort();
bool NiceHashMode();
bool PreferIpv4();
inline bool HaveHardwareAes() { return bHaveAes; }
+8 -2
View File
@@ -350,7 +350,10 @@ void minethd::work_main()
continue;
}
result.iNonce = calc_start_nonce(oWork.iResumeCnt);
if(oWork.bNiceHash)
result.iNonce = calc_nicehash_nonce(*piNonce, oWork.iResumeCnt);
else
result.iNonce = calc_start_nonce(oWork.iResumeCnt);
assert(sizeof(job_result::sJobID) == sizeof(pool_job::sJobID));
memcpy(result.sJobID, oWork.sJobID, sizeof(job_result::sJobID));
@@ -430,7 +433,10 @@ void minethd::double_work_main()
continue;
}
iNonce = calc_start_nonce(oWork.iResumeCnt);
if(oWork.bNiceHash)
iNonce = calc_nicehash_nonce(*piNonce0, oWork.iResumeCnt);
else
iNonce = calc_start_nonce(oWork.iResumeCnt);
assert(sizeof(job_result::sJobID) == sizeof(pool_job::sJobID));
+9 -2
View File
@@ -27,14 +27,15 @@ public:
uint32_t iWorkSize;
uint32_t iResumeCnt;
uint64_t iTarget;
bool bNiceHash;
bool bStall;
size_t iPoolId;
miner_work() : iWorkSize(0), bStall(true), iPoolId(0) { }
miner_work(const char* sJobID, const uint8_t* bWork, uint32_t iWorkSize, uint32_t iResumeCnt,
uint64_t iTarget, size_t iPoolId) : iWorkSize(iWorkSize), iResumeCnt(iResumeCnt),
iTarget(iTarget), bStall(false), iPoolId(iPoolId)
uint64_t iTarget, bool bNiceHash, size_t iPoolId) : iWorkSize(iWorkSize), iResumeCnt(iResumeCnt),
iTarget(iTarget), bNiceHash(bNiceHash), bStall(false), iPoolId(iPoolId)
{
assert(iWorkSize <= sizeof(bWorkBlob));
memcpy(this->sJobID, sJobID, sizeof(miner_work::sJobID));
@@ -50,6 +51,7 @@ public:
iWorkSize = from.iWorkSize;
iResumeCnt = from.iResumeCnt;
iTarget = from.iTarget;
bNiceHash = from.bNiceHash;
bStall = from.bStall;
iPoolId = from.iPoolId;
@@ -75,6 +77,7 @@ public:
iWorkSize = from.iWorkSize;
iResumeCnt = from.iResumeCnt;
iTarget = from.iTarget;
bNiceHash = from.bNiceHash;
bStall = from.bStall;
iPoolId = from.iPoolId;
@@ -103,6 +106,10 @@ private:
inline uint32_t calc_start_nonce(uint32_t resume)
{ return (resume * iThreadCount + iThreadNo) << 22; }
// Limited version of the nonce calc above
inline uint32_t calc_nicehash_nonce(uint32_t start, uint32_t resume)
{ return start | (resume * iThreadCount + iThreadNo) << 18; }
void work_main();
void double_work_main();
void consume_work();