mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 20:44:19 +00:00
Generate the output hash for scrypt as well and use the one function to set share_diff.
This commit is contained in:
parent
f86e893118
commit
f0c1782c03
63
cgminer.c
63
cgminer.c
@ -2342,7 +2342,10 @@ static uint64_t share_diff(const struct work *work)
|
|||||||
uint64_t ret;
|
uint64_t ret;
|
||||||
|
|
||||||
swab256(rhash, work->hash);
|
swab256(rhash, work->hash);
|
||||||
data64 = (uint64_t *)(rhash + 4);
|
if (opt_scrypt)
|
||||||
|
data64 = (uint64_t *)(rhash + 2);
|
||||||
|
else
|
||||||
|
data64 = (uint64_t *)(rhash + 4);
|
||||||
d64 = be64toh(*data64);
|
d64 = be64toh(*data64);
|
||||||
if (unlikely(!d64))
|
if (unlikely(!d64))
|
||||||
d64 = 1;
|
d64 = 1;
|
||||||
@ -2356,23 +2359,6 @@ static uint64_t share_diff(const struct work *work)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint64_t scrypt_diff(const struct work *work)
|
|
||||||
{
|
|
||||||
const uint64_t scrypt_diffone = 0x0000ffff00000000ul;
|
|
||||||
uint64_t d64 = work->outputhash, ret;
|
|
||||||
|
|
||||||
if (unlikely(!d64))
|
|
||||||
d64 = 1;
|
|
||||||
ret = scrypt_diffone / d64;
|
|
||||||
mutex_lock(&control_lock);
|
|
||||||
if (ret > best_diff) {
|
|
||||||
best_diff = ret;
|
|
||||||
suffix_string(best_diff, best_share, 0);
|
|
||||||
}
|
|
||||||
mutex_unlock(&control_lock);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
|
static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
|
||||||
{
|
{
|
||||||
char *hexstr = NULL;
|
char *hexstr = NULL;
|
||||||
@ -2383,7 +2369,6 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
|
|||||||
struct cgpu_info *cgpu = thr_info[thr_id].cgpu;
|
struct cgpu_info *cgpu = thr_info[thr_id].cgpu;
|
||||||
struct pool *pool = work->pool;
|
struct pool *pool = work->pool;
|
||||||
int rolltime;
|
int rolltime;
|
||||||
uint32_t *hash32;
|
|
||||||
struct timeval tv_submit, tv_submit_reply;
|
struct timeval tv_submit, tv_submit_reply;
|
||||||
char hashshow[64 + 4] = "";
|
char hashshow[64 + 4] = "";
|
||||||
char worktime[200] = "";
|
char worktime[200] = "";
|
||||||
@ -2464,26 +2449,20 @@ static bool submit_upstream_work(struct work *work, CURL *curl, bool resubmit)
|
|||||||
|
|
||||||
if (!QUIET) {
|
if (!QUIET) {
|
||||||
int intdiff = floor(work->work_difficulty);
|
int intdiff = floor(work->work_difficulty);
|
||||||
|
char diffdisp[16], *outhash;
|
||||||
|
unsigned char rhash[32];
|
||||||
uint64_t sharediff;
|
uint64_t sharediff;
|
||||||
char diffdisp[16];
|
|
||||||
|
|
||||||
hash32 = (uint32_t *)(work->hash);
|
swab256(rhash, work->hash);
|
||||||
if (opt_scrypt) {
|
if (opt_scrypt)
|
||||||
uint64_t outhash;
|
outhash = bin2hex(rhash + 2, 4);
|
||||||
|
else
|
||||||
scrypt_outputhash(work);
|
outhash = bin2hex(rhash + 4, 4);
|
||||||
sharediff = scrypt_diff(work);
|
sharediff = share_diff(work);
|
||||||
suffix_string(sharediff, diffdisp, 0);
|
suffix_string(sharediff, diffdisp, 0);
|
||||||
|
sprintf(hashshow, "%s Diff %s/%d%s", outhash, diffdisp, intdiff,
|
||||||
outhash = work->outputhash >> 16;
|
work->block? " BLOCK!" : "");
|
||||||
sprintf(hashshow, "%08lx Diff %s/%d", (unsigned long)outhash, diffdisp, intdiff);
|
free(outhash);
|
||||||
} else {
|
|
||||||
sharediff = share_diff(work);
|
|
||||||
suffix_string(sharediff, diffdisp, 0);
|
|
||||||
|
|
||||||
sprintf(hashshow, "%08lx Diff %s/%d%s", (unsigned long)(hash32[6]), diffdisp, intdiff,
|
|
||||||
work->block? " BLOCK!" : "");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (opt_worktime) {
|
if (opt_worktime) {
|
||||||
char workclone[20];
|
char workclone[20];
|
||||||
@ -3095,16 +3074,20 @@ static bool stale_work(struct work *work, bool share)
|
|||||||
|
|
||||||
static void check_solve(struct work *work)
|
static void check_solve(struct work *work)
|
||||||
{
|
{
|
||||||
|
if (opt_scrypt)
|
||||||
|
scrypt_outputhash(work);
|
||||||
|
else {
|
||||||
#ifndef MIPSEB
|
#ifndef MIPSEB
|
||||||
/* This segfaults on openwrt */
|
/* This segfaults on openwrt */
|
||||||
work->block = regeneratehash(work);
|
work->block = regeneratehash(work);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if (unlikely(work->block)) {
|
if (unlikely(work->block)) {
|
||||||
work->pool->solved++;
|
work->pool->solved++;
|
||||||
found_blocks++;
|
found_blocks++;
|
||||||
work->mandatory = true;
|
work->mandatory = true;
|
||||||
applog(LOG_NOTICE, "Found block for pool %d!", work->pool->pool_no);
|
applog(LOG_NOTICE, "Found block for pool %d!", work->pool->pool_no);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *submit_work_thread(void *userdata)
|
static void *submit_work_thread(void *userdata)
|
||||||
|
2
miner.h
2
miner.h
@ -972,8 +972,6 @@ struct work {
|
|||||||
unsigned char target[32];
|
unsigned char target[32];
|
||||||
unsigned char hash[32];
|
unsigned char hash[32];
|
||||||
|
|
||||||
uint64_t outputhash;
|
|
||||||
|
|
||||||
int rolls;
|
int rolls;
|
||||||
|
|
||||||
dev_blk_ctx blk;
|
dev_blk_ctx blk;
|
||||||
|
6
scrypt.c
6
scrypt.c
@ -407,16 +407,16 @@ static void scrypt_1024_1_1_256_sp(const uint32_t* input, char* scratchpad, uint
|
|||||||
|
|
||||||
void scrypt_outputhash(struct work *work)
|
void scrypt_outputhash(struct work *work)
|
||||||
{
|
{
|
||||||
uint32_t data[20], ohash[8], rhash[8];
|
uint32_t data[20];
|
||||||
char *scratchbuf;
|
char *scratchbuf;
|
||||||
uint32_t *nonce = (uint32_t *)(work->data + 76);
|
uint32_t *nonce = (uint32_t *)(work->data + 76);
|
||||||
|
uint32_t *ohash = (uint32_t *)(work->hash);
|
||||||
|
|
||||||
be32enc_vect(data, (const uint32_t *)work->data, 19);
|
be32enc_vect(data, (const uint32_t *)work->data, 19);
|
||||||
data[19] = htobe32(*nonce);
|
data[19] = htobe32(*nonce);
|
||||||
scratchbuf = alloca(SCRATCHBUF_SIZE);
|
scratchbuf = alloca(SCRATCHBUF_SIZE);
|
||||||
scrypt_1024_1_1_256_sp(data, scratchbuf, ohash);
|
scrypt_1024_1_1_256_sp(data, scratchbuf, ohash);
|
||||||
swap256(rhash, ohash);
|
flip32(ohash, ohash);
|
||||||
work->outputhash = be64toh(*((uint64_t *)rhash));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Used externally as confirmation of correct OCL code */
|
/* Used externally as confirmation of correct OCL code */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user