Backport changes from xmrig-aeon.
This commit is contained in:
parent
3de7983826
commit
caf7cda1d5
4 changed files with 31 additions and 67 deletions
53
xmrig.c
53
xmrig.c
|
@ -70,14 +70,6 @@ static bool g_want_donate = false;
|
|||
static void workio_cmd_free(struct workio_cmd *wc);
|
||||
|
||||
|
||||
/**
|
||||
* @brief work_free
|
||||
* @param w
|
||||
*/
|
||||
static inline void work_free(struct work *w) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @brief work_copy
|
||||
* @param dest
|
||||
|
@ -149,7 +141,6 @@ static bool submit_upstream_work(struct work *work) {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -164,7 +155,6 @@ static void workio_cmd_free(struct workio_cmd *wc) {
|
|||
return;
|
||||
}
|
||||
|
||||
work_free(wc->work);
|
||||
free(wc->work);
|
||||
|
||||
memset(wc, 0, sizeof(*wc)); /* poison */
|
||||
|
@ -265,7 +255,7 @@ static bool should_pause(int thr_id) {
|
|||
*/
|
||||
static void *miner_thread(void *userdata) {
|
||||
struct thr_info *mythr = userdata;
|
||||
int thr_id = mythr->id;
|
||||
const int thr_id = mythr->id;
|
||||
struct work work = { { 0 } };
|
||||
uint32_t max_nonce;
|
||||
uint32_t end_nonce = 0xffffffffU / opt_n_threads * (thr_id + 1) - 0x20;
|
||||
|
@ -276,15 +266,10 @@ static void *miner_thread(void *userdata) {
|
|||
affine_to_cpu_mask(thr_id, (unsigned long) opt_affinity);
|
||||
}
|
||||
|
||||
uint32_t *nonceptr = (uint32_t*) (((char*)work.blob) + 39);
|
||||
uint32_t *nonceptr = NULL;
|
||||
uint32_t hash[8] __attribute__((aligned(32)));
|
||||
|
||||
while (1) {
|
||||
unsigned long hashes_done;
|
||||
struct timeval tv_start;
|
||||
int64_t max64;
|
||||
int rc;
|
||||
|
||||
if (should_pause(thr_id)) {
|
||||
sleep(1);
|
||||
continue;
|
||||
|
@ -292,46 +277,38 @@ static void *miner_thread(void *userdata) {
|
|||
|
||||
pthread_mutex_lock(&stratum_ctx->work_lock);
|
||||
|
||||
if (memcmp(work.blob, stratum_ctx->g_work.blob, 39) || memcmp(((uint8_t*) work.blob) + 43, ((uint8_t*) stratum_ctx->g_work.blob) + 43, 33)) {
|
||||
work_free(&work);
|
||||
if (memcmp(work.job_id, stratum_ctx->g_work.job_id, 64)) {
|
||||
work_copy(&work, &stratum_ctx->g_work);
|
||||
nonceptr = (uint32_t*) (((char*) work.blob) + 39);
|
||||
*nonceptr = 0xffffffffU / opt_n_threads * thr_id;
|
||||
} else {
|
||||
++(*nonceptr);
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&stratum_ctx->work_lock);
|
||||
|
||||
work_restart[thr_id].restart = 0;
|
||||
|
||||
/* adjust max_nonce to meet target scan time */
|
||||
max64 = LP_SCANTIME;
|
||||
|
||||
//max64 *= thr_hashrates[thr_id];
|
||||
if (max64 <= 0) {
|
||||
max64 = 0x40LL;
|
||||
}
|
||||
|
||||
if (*nonceptr + max64 > end_nonce) {
|
||||
if (*nonceptr + LP_SCANTIME > end_nonce) {
|
||||
max_nonce = end_nonce;
|
||||
} else {
|
||||
max_nonce = *nonceptr + max64;
|
||||
max_nonce = *nonceptr + LP_SCANTIME;
|
||||
}
|
||||
|
||||
hashes_done = 0;
|
||||
gettimeofday(&tv_start, NULL );
|
||||
unsigned long hashes_done = 0;
|
||||
|
||||
struct timeval tv_start;
|
||||
gettimeofday(&tv_start, NULL);
|
||||
|
||||
/* scan nonces for a proof-of-work hash */
|
||||
rc = scanhash_cryptonight(thr_id, hash, work.blob, work.blob_size, work.target, max_nonce, &hashes_done, persistentctx);
|
||||
const int rc = scanhash_cryptonight(thr_id, hash, work.blob, work.blob_size, work.target, max_nonce, &hashes_done, persistentctx);
|
||||
stats_add_hashes(thr_id, &tv_start, hashes_done);
|
||||
|
||||
memcpy(work.hash, hash, 32);
|
||||
|
||||
/* if nonce found, submit work */
|
||||
if (rc && !submit_work(mythr, &work)) {
|
||||
if (!rc) {
|
||||
continue;
|
||||
}
|
||||
|
||||
memcpy(work.hash, hash, 32);
|
||||
submit_work(mythr, &work);
|
||||
++(*nonceptr);
|
||||
}
|
||||
|
||||
tq_freeze(mythr->q);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue