mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-22 12:34:27 +00:00
Make scrypt submission use the submit_nonce code, with nonces matching endianness.
This commit is contained in:
parent
c1ff90a7ab
commit
bc0e71448e
@ -75,7 +75,6 @@ static inline void affine_to_cpu(int __maybe_unused id, int __maybe_unused cpu)
|
|||||||
|
|
||||||
|
|
||||||
/* TODO: resolve externals */
|
/* TODO: resolve externals */
|
||||||
extern void submit_work_async(const struct work *work_in, struct timeval *tv);
|
|
||||||
extern char *set_int_range(const char *arg, int *i, int min, int max);
|
extern char *set_int_range(const char *arg, int *i, int min, int max);
|
||||||
extern int dev_from_id(int thr_id);
|
extern int dev_from_id(int thr_id);
|
||||||
|
|
||||||
@ -833,7 +832,7 @@ CPUSearch:
|
|||||||
/* if nonce found, submit work */
|
/* if nonce found, submit work */
|
||||||
if (unlikely(rc)) {
|
if (unlikely(rc)) {
|
||||||
applog(LOG_DEBUG, "CPU %d found something?", dev_from_id(thr_id));
|
applog(LOG_DEBUG, "CPU %d found something?", dev_from_id(thr_id));
|
||||||
submit_work_async(work, NULL);
|
submit_nonce(thr, work, last_nonce);
|
||||||
work->blk.nonce = last_nonce + 1;
|
work->blk.nonce = last_nonce + 1;
|
||||||
goto CPUSearch;
|
goto CPUSearch;
|
||||||
}
|
}
|
||||||
|
15
scrypt.c
15
scrypt.c
@ -419,10 +419,12 @@ void scrypt_regenhash(struct work *work)
|
|||||||
flip32(ohash, ohash);
|
flip32(ohash, ohash);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const uint32_t diff1targ = 0x0000ffff;
|
||||||
|
|
||||||
/* Used externally as confirmation of correct OCL code */
|
/* Used externally as confirmation of correct OCL code */
|
||||||
int scrypt_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce)
|
int scrypt_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t nonce)
|
||||||
{
|
{
|
||||||
uint32_t tmp_hash7, Htarg = ((const uint32_t *)ptarget)[7];
|
uint32_t tmp_hash7, Htarg = le32toh(((const uint32_t *)ptarget)[7]);
|
||||||
uint32_t data[20], ohash[8];
|
uint32_t data[20], ohash[8];
|
||||||
char *scratchbuf;
|
char *scratchbuf;
|
||||||
|
|
||||||
@ -432,10 +434,11 @@ int scrypt_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t non
|
|||||||
scrypt_1024_1_1_256_sp(data, scratchbuf, ohash);
|
scrypt_1024_1_1_256_sp(data, scratchbuf, ohash);
|
||||||
tmp_hash7 = be32toh(ohash[7]);
|
tmp_hash7 = be32toh(ohash[7]);
|
||||||
|
|
||||||
/* FIXME: Needs to be able to return 0 as well for not meeting target
|
applog(LOG_DEBUG, "harget %08lx diff1 %08lx hash %08lx", Htarg, diff1targ, tmp_hash7);
|
||||||
* but target diff currently is sent to devices. */
|
if (tmp_hash7 > diff1targ)
|
||||||
if (tmp_hash7 > Htarg)
|
|
||||||
return -1;
|
return -1;
|
||||||
|
if (tmp_hash7 > Htarg)
|
||||||
|
return 0;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -448,7 +451,7 @@ bool scanhash_scrypt(struct thr_info *thr, const unsigned char __maybe_unused *p
|
|||||||
char *scratchbuf;
|
char *scratchbuf;
|
||||||
uint32_t data[20];
|
uint32_t data[20];
|
||||||
uint32_t tmp_hash7;
|
uint32_t tmp_hash7;
|
||||||
uint32_t Htarg = ((const uint32_t *)ptarget)[7];
|
uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]);
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
be32enc_vect(data, (const uint32_t *)pdata, 19);
|
be32enc_vect(data, (const uint32_t *)pdata, 19);
|
||||||
@ -463,7 +466,7 @@ bool scanhash_scrypt(struct thr_info *thr, const unsigned char __maybe_unused *p
|
|||||||
uint32_t ostate[8];
|
uint32_t ostate[8];
|
||||||
|
|
||||||
*nonce = ++n;
|
*nonce = ++n;
|
||||||
data[19] = n;
|
data[19] = htobe32(n);
|
||||||
scrypt_1024_1_1_256_sp(data, scratchbuf, ostate);
|
scrypt_1024_1_1_256_sp(data, scratchbuf, ostate);
|
||||||
tmp_hash7 = be32toh(ostate[7]);
|
tmp_hash7 = be32toh(ostate[7]);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user