Browse Source

Make scrypt submission use the submit_nonce code, with nonces matching endianness.

nfactor-troky
Con Kolivas 12 years ago
parent
commit
bc0e71448e
  1. 3
      driver-cpu.c
  2. 15
      scrypt.c

3
driver-cpu.c

@ -75,7 +75,6 @@ static inline void affine_to_cpu(int __maybe_unused id, int __maybe_unused cpu) @@ -75,7 +75,6 @@ static inline void affine_to_cpu(int __maybe_unused id, int __maybe_unused cpu)
/* 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 int dev_from_id(int thr_id);
@ -833,7 +832,7 @@ CPUSearch: @@ -833,7 +832,7 @@ CPUSearch:
/* if nonce found, submit work */
if (unlikely(rc)) {
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;
goto CPUSearch;
}

15
scrypt.c

@ -419,10 +419,12 @@ void scrypt_regenhash(struct work *work) @@ -419,10 +419,12 @@ void scrypt_regenhash(struct work *work)
flip32(ohash, ohash);
}
static const uint32_t diff1targ = 0x0000ffff;
/* Used externally as confirmation of correct OCL code */
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];
char *scratchbuf;
@ -432,10 +434,11 @@ int scrypt_test(unsigned char *pdata, const unsigned char *ptarget, uint32_t non @@ -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);
tmp_hash7 = be32toh(ohash[7]);
/* FIXME: Needs to be able to return 0 as well for not meeting target
* but target diff currently is sent to devices. */
if (tmp_hash7 > Htarg)
applog(LOG_DEBUG, "harget %08lx diff1 %08lx hash %08lx", Htarg, diff1targ, tmp_hash7);
if (tmp_hash7 > diff1targ)
return -1;
if (tmp_hash7 > Htarg)
return 0;
return 1;
}
@ -448,7 +451,7 @@ bool scanhash_scrypt(struct thr_info *thr, const unsigned char __maybe_unused *p @@ -448,7 +451,7 @@ bool scanhash_scrypt(struct thr_info *thr, const unsigned char __maybe_unused *p
char *scratchbuf;
uint32_t data[20];
uint32_t tmp_hash7;
uint32_t Htarg = ((const uint32_t *)ptarget)[7];
uint32_t Htarg = le32toh(((const uint32_t *)ptarget)[7]);
bool ret = false;
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 @@ -463,7 +466,7 @@ bool scanhash_scrypt(struct thr_info *thr, const unsigned char __maybe_unused *p
uint32_t ostate[8];
*nonce = ++n;
data[19] = n;
data[19] = htobe32(n);
scrypt_1024_1_1_256_sp(data, scratchbuf, ostate);
tmp_hash7 = be32toh(ostate[7]);

Loading…
Cancel
Save