Browse Source

Refactor the CPU scanhash_* functions to use a common API. Fixes bugs.

- Before, some returned bool, and others returned int (which was then turned
  into a bool with a comparison); now, everything returns a bool
- Before, some set hashes_done to nonce - 1 when a share was found and others
  set it to nonce + 1 or 2. This caused some algorithms to scan/submit shares
  twice with the new cpu_scanhash function. Now, it has all been replaced with
  last_nonce, which is set to the final nonce checked by the scanhash_* func.
- VIA needs the full data, and cannot use midstate. All the others were
  expecting midstate and data+64 for their parameters. Now, we pass midstate
  and the full data pointer, and let the scanhash_* function choose which to
  use.
nfactor-troky
Luke Dashjr 13 years ago
parent
commit
b9d197dee8
  1. 140
      main.c
  2. 45
      miner.h
  3. 19
      sha256_4way.c
  4. 19
      sha256_altivec_4way.c
  5. 20
      sha256_cryptopp.c
  6. 10
      sha256_generic.c
  7. 23
      sha256_sse2_amd64.c
  8. 25
      sha256_sse2_i386.c
  9. 23
      sha256_sse4_amd64.c
  10. 10
      sha256_via.c

140
main.c

@ -146,7 +146,6 @@ const char *algo_names[] = { @@ -146,7 +146,6 @@ const char *algo_names[] = {
#endif
};
typedef void (*sha256_func)();
static const sha256_func sha256_funcs[] = {
[ALGO_C] = (sha256_func)scanhash_c,
#ifdef WANT_SSE2_4WAY
@ -488,34 +487,20 @@ static double bench_algo_stage3( @@ -488,34 +487,20 @@ static double bench_algo_stage3(
struct timeval end;
struct timeval start;
uint32_t max_nonce = (1<<22);
unsigned long hashes_done = 0;
uint32_t last_nonce = 0;
gettimeofday(&start, 0);
#if defined(WANT_VIA_PADLOCK)
// For some reason, the VIA padlock hasher has a different API ...
if (ALGO_VIA==algo) {
(void)scanhash_via(
0,
work.data,
work.target,
max_nonce,
&hashes_done,
work.blk.nonce
);
} else
#endif
{
sha256_func func = sha256_funcs[algo];
(*func)(
0,
work.midstate,
work.data + 64,
work.data,
work.hash1,
work.hash,
work.target,
max_nonce,
&hashes_done,
&last_nonce,
work.blk.nonce
);
}
@ -528,7 +513,7 @@ static double bench_algo_stage3( @@ -528,7 +513,7 @@ static double bench_algo_stage3(
double rate = -1.0;
if (0<usec_elapsed) {
rate = (1.0*hashes_done)/usec_elapsed;
rate = (1.0*(last_nonce+1))/usec_elapsed;
}
return rate;
}
@ -5465,102 +5450,28 @@ static uint64_t cpu_scanhash(struct thr_info *thr, struct work *work, uint64_t m @@ -5465,102 +5450,28 @@ static uint64_t cpu_scanhash(struct thr_info *thr, struct work *work, uint64_t m
{
const int thr_id = thr->id;
long unsigned int hashes_done = 0;
uint32_t first_nonce = work->blk.nonce;
bool rc = false;
uint32_t last_nonce;
bool rc;
CPUSearch:
last_nonce = first_nonce;
rc = false;
/* scan nonces for a proof-of-work hash */
switch (opt_algo) {
case ALGO_C:
rc = scanhash_c(thr_id, work->midstate, work->data + 64,
work->hash1, work->hash, work->target,
max_nonce, &hashes_done,
work->blk.nonce);
break;
#ifdef WANT_X8632_SSE2
case ALGO_SSE2_32: {
unsigned int rc5 =
scanhash_sse2_32(thr_id, work->midstate, work->data + 64,
work->hash1, work->hash,
work->target,
max_nonce, &hashes_done,
work->blk.nonce);
rc = (rc5 == -1) ? false : true;
}
break;
#endif
#ifdef WANT_X8664_SSE2
case ALGO_SSE2_64: {
unsigned int rc5 =
scanhash_sse2_64(thr_id, work->midstate, work->data + 64,
work->hash1, work->hash,
work->target,
max_nonce, &hashes_done,
work->blk.nonce);
rc = (rc5 == -1) ? false : true;
}
break;
#endif
#ifdef WANT_X8664_SSE4
case ALGO_SSE4_64: {
unsigned int rc5 =
scanhash_sse4_64(thr_id, work->midstate, work->data + 64,
work->hash1, work->hash,
work->target,
max_nonce, &hashes_done,
work->blk.nonce);
rc = (rc5 == -1) ? false : true;
}
break;
#endif
#ifdef WANT_SSE2_4WAY
case ALGO_4WAY: {
unsigned int rc4 =
ScanHash_4WaySSE2(thr_id, work->midstate, work->data + 64,
work->hash1, work->hash,
work->target,
max_nonce, &hashes_done,
work->blk.nonce);
rc = (rc4 == -1) ? false : true;
}
break;
#endif
#ifdef WANT_ALTIVEC_4WAY
case ALGO_ALTIVEC_4WAY:
{
unsigned int rc4 = ScanHash_altivec_4way(thr_id, work->midstate, work->data + 64,
work->hash1, work->hash,
sha256_func func = sha256_funcs[opt_algo];
rc = (*func)(
thr_id,
work->midstate,
work->data,
work->hash1,
work->hash,
work->target,
max_nonce, &hashes_done,
work->blk.nonce);
rc = (rc4 == -1) ? false : true;
}
break;
#endif
#ifdef WANT_VIA_PADLOCK
case ALGO_VIA:
rc = scanhash_via(thr_id, work->data, work->target,
max_nonce, &hashes_done,
work->blk.nonce);
break;
#endif
case ALGO_CRYPTOPP:
rc = scanhash_cryptopp(thr_id, work->midstate, work->data + 64,
work->hash1, work->hash, work->target,
max_nonce, &hashes_done,
work->blk.nonce);
break;
#ifdef WANT_CRYPTOPP_ASM32
case ALGO_CRYPTOPP_ASM32:
rc = scanhash_asm32(thr_id, work->midstate, work->data + 64,
work->hash1, work->hash, work->target,
max_nonce, &hashes_done,
work->blk.nonce);
break;
#endif
default:
/* should never happen */
applog(LOG_ERR, "Unrecognized hash algorithm! This should be impossible!");
max_nonce,
&last_nonce,
work->blk.nonce
);
}
/* if nonce found, submit work */
@ -5570,10 +5481,15 @@ static uint64_t cpu_scanhash(struct thr_info *thr, struct work *work, uint64_t m @@ -5570,10 +5481,15 @@ static uint64_t cpu_scanhash(struct thr_info *thr, struct work *work, uint64_t m
if (unlikely(!submit_work_sync(thr, work))) {
applog(LOG_ERR, "Failed to submit_work_sync in miner_thread %d", thr_id);
}
work->blk.nonce = last_nonce + 1;
goto CPUSearch;
}
else
if (unlikely(last_nonce == first_nonce))
return 0;
work->blk.nonce = hashes_done;
return (uint64_t)hashes_done - first_nonce;
work->blk.nonce = last_nonce + 1;
return last_nonce - first_nonce + 1;
}
struct device_api cpu_api = {

45
miner.h

@ -381,57 +381,62 @@ extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass, @@ -381,57 +381,62 @@ extern json_t *json_rpc_call(CURL *curl, const char *url, const char *userpass,
extern char *bin2hex(const unsigned char *p, size_t len);
extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
extern unsigned int ScanHash_4WaySSE2(int, const unsigned char *pmidstate,
unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, unsigned long *nHashesDone, uint32_t nonce);
extern unsigned int ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
typedef bool (*sha256_func)(int thr_id, const unsigned char *pmidstate,
unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, unsigned long *nHashesDone, uint32_t nonce);
uint32_t max_nonce,
uint32_t *last_nonce,
uint32_t nonce);
extern unsigned int scanhash_sse2_amd64(int, const unsigned char *pmidstate,
extern bool ScanHash_4WaySSE2(int, const unsigned char *pmidstate,
unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, unsigned long *nHashesDone);
uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
extern bool ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
extern bool scanhash_via(int, unsigned char *data_inout,
extern bool scanhash_via(int, const unsigned char *pmidstate,
unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *target,
uint32_t max_nonce, unsigned long *hashes_done, uint32_t n);
uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
extern bool scanhash_c(int, const unsigned char *midstate, unsigned char *data,
unsigned char *hash1, unsigned char *hash,
const unsigned char *target,
uint32_t max_nonce, unsigned long *hashes_done, uint32_t n);
uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
extern bool scanhash_cryptopp(int, const unsigned char *midstate,unsigned char *data,
unsigned char *hash1, unsigned char *hash,
const unsigned char *target,
uint32_t max_nonce, unsigned long *hashes_done, uint32_t n);
uint32_t max_nonce, uint32_t *last_nonce, uint32_t n);
extern bool scanhash_asm32(int, const unsigned char *midstate,unsigned char *data,
unsigned char *hash1, unsigned char *hash,
const unsigned char *target,
uint32_t max_nonce, unsigned long *hashes_done, uint32_t nonce);
uint32_t max_nonce, uint32_t *last_nonce, uint32_t nonce);
extern int scanhash_sse2_64(int, const unsigned char *pmidstate, unsigned char *pdata,
extern bool scanhash_sse2_64(int, const unsigned char *pmidstate, unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, unsigned long *nHashesDone,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t nonce);
extern int scanhash_sse4_64(int, const unsigned char *pmidstate, unsigned char *pdata,
extern bool scanhash_sse4_64(int, const unsigned char *pmidstate, unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, unsigned long *nHashesDone,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t nonce);
extern int scanhash_sse2_32(int, const unsigned char *pmidstate, unsigned char *pdata,
extern bool scanhash_sse2_32(int, const unsigned char *pmidstate, unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, unsigned long *nHashesDone,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t nonce);
extern int

19
sha256_4way.c

@ -101,14 +101,16 @@ static const unsigned int pSHA256InitState[8] = @@ -101,14 +101,16 @@ static const unsigned int pSHA256InitState[8] =
{0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
unsigned int ScanHash_4WaySSE2(int thr_id, const unsigned char *pmidstate,
bool ScanHash_4WaySSE2(int thr_id, const unsigned char *pmidstate,
unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, unsigned long *nHashesDone,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t nonce)
{
unsigned int *nNonce_p = (unsigned int*)(pdata + 12);
unsigned int *nNonce_p = (unsigned int*)(pdata + 76);
pdata += 64;
work_restart[thr_id].restart = 0;
@ -132,17 +134,18 @@ unsigned int ScanHash_4WaySSE2(int thr_id, const unsigned char *pmidstate, @@ -132,17 +134,18 @@ unsigned int ScanHash_4WaySSE2(int thr_id, const unsigned char *pmidstate,
((unsigned int*)phash)[i] = thash[i][j];
if (fulltest(phash, ptarget)) {
*nHashesDone = nonce;
*nNonce_p = nonce + j;
return nonce + j;
nonce += j;
*last_nonce = nonce;
*nNonce_p = nonce;
return true;
}
}
}
if ((nonce >= max_nonce) || work_restart[thr_id].restart)
{
*nHashesDone = nonce;
return -1;
*last_nonce = nonce;
return false;
}
}
}

19
sha256_altivec_4way.c

@ -74,14 +74,16 @@ static const unsigned int pSHA256InitState[8] = @@ -74,14 +74,16 @@ static const unsigned int pSHA256InitState[8] =
{0x6a09e667, 0xbb67ae85, 0x3c6ef372, 0xa54ff53a, 0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19};
unsigned int ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
bool ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, unsigned long *nHashesDone,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t nonce)
{
unsigned int *nNonce_p = (unsigned int*)(pdata + 12);
unsigned int *nNonce_p = (unsigned int*)(pdata + 76);
pdata += 64;
work_restart[thr_id].restart = 0;
@ -104,17 +106,18 @@ unsigned int ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate, @@ -104,17 +106,18 @@ unsigned int ScanHash_altivec_4way(int thr_id, const unsigned char *pmidstate,
((unsigned int*)phash)[i] = thash[i][j];
if (fulltest(phash, ptarget)) {
*nHashesDone = nonce;
*nNonce_p = nonce + j;
return nonce + j;
nonce += j;
*last_nonce = nonce;
*nNonce_p = nonce;
return true;
}
}
}
if ((nonce >= max_nonce) || work_restart[thr_id].restart)
{
*nHashesDone = nonce;
return -1;
*last_nonce = nonce;
return false;
}
nonce += NPAR;

20
sha256_cryptopp.c

@ -97,11 +97,13 @@ bool scanhash_cryptopp(int thr_id, const unsigned char *midstate, @@ -97,11 +97,13 @@ bool scanhash_cryptopp(int thr_id, const unsigned char *midstate,
unsigned char *data,
unsigned char *hash1, unsigned char *hash,
const unsigned char *target,
uint32_t max_nonce, unsigned long *hashes_done,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t n)
{
uint32_t *hash32 = (uint32_t *) hash;
uint32_t *nonce = (uint32_t *)(data + 12);
uint32_t *nonce = (uint32_t *)(data + 76);
data += 64;
work_restart[thr_id].restart = 0;
@ -113,12 +115,12 @@ bool scanhash_cryptopp(int thr_id, const unsigned char *midstate, @@ -113,12 +115,12 @@ bool scanhash_cryptopp(int thr_id, const unsigned char *midstate,
runhash(hash, hash1, sha256_init_state);
if (unlikely((hash32[7] == 0) && fulltest(hash, target))) {
*hashes_done = n;
*last_nonce = n;
return true;
}
if ((n >= max_nonce) || work_restart[thr_id].restart) {
*hashes_done = n;
*last_nonce = n;
return false;
}
}
@ -579,11 +581,13 @@ bool scanhash_asm32(int thr_id, const unsigned char *midstate, @@ -579,11 +581,13 @@ bool scanhash_asm32(int thr_id, const unsigned char *midstate,
unsigned char *data,
unsigned char *hash1, unsigned char *hash,
const unsigned char *target,
uint32_t max_nonce, unsigned long *hashes_done,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t n)
{
uint32_t *hash32 = (uint32_t *) hash;
uint32_t *nonce = (uint32_t *)(data + 12);
uint32_t *nonce = (uint32_t *)(data + 76);
data += 64;
work_restart[thr_id].restart = 0;
@ -595,12 +599,12 @@ bool scanhash_asm32(int thr_id, const unsigned char *midstate, @@ -595,12 +599,12 @@ bool scanhash_asm32(int thr_id, const unsigned char *midstate,
runhash32(hash, hash1, sha256_init_state);
if (unlikely((hash32[7] == 0) && fulltest(hash, target))) {
*hashes_done = n;
*last_nonce = n;
return true;
}
if ((n >= max_nonce) || work_restart[thr_id].restart) {
*hashes_done = n;
*last_nonce = n;
return false;
}
}

10
sha256_generic.c

@ -242,13 +242,15 @@ const uint32_t sha256_init_state[8] = { @@ -242,13 +242,15 @@ const uint32_t sha256_init_state[8] = {
bool scanhash_c(int thr_id, const unsigned char *midstate, unsigned char *data,
unsigned char *hash1, unsigned char *hash,
const unsigned char *target,
uint32_t max_nonce, unsigned long *hashes_done,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t n)
{
uint32_t *hash32 = (uint32_t *) hash;
uint32_t *nonce = (uint32_t *)(data + 12);
uint32_t *nonce = (uint32_t *)(data + 76);
unsigned long stat_ctr = 0;
data += 64;
work_restart[thr_id].restart = 0;
while (1) {
@ -261,12 +263,12 @@ bool scanhash_c(int thr_id, const unsigned char *midstate, unsigned char *data, @@ -261,12 +263,12 @@ bool scanhash_c(int thr_id, const unsigned char *midstate, unsigned char *data,
stat_ctr++;
if (unlikely((hash32[7] == 0) && fulltest(hash, target))) {
*hashes_done = n;
*last_nonce = n;
return true;
}
if ((n >= max_nonce) || work_restart[thr_id].restart) {
*hashes_done = n;
*last_nonce = n;
return false;
}
}

23
sha256_sse2_amd64.c

@ -50,14 +50,14 @@ const uint32_t sha256_init[8]__attribute__((aligned(0x100))) = @@ -50,14 +50,14 @@ const uint32_t sha256_init[8]__attribute__((aligned(0x100))) =
__m128i g_4sha256_k[64];
__m128i sha256_consts_m128i[64]__attribute__((aligned(0x1000)));
int scanhash_sse2_64(int thr_id, const unsigned char *pmidstate,
bool scanhash_sse2_64(int thr_id, const unsigned char *pmidstate,
unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, unsigned long *nHashesDone,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t nonce)
{
uint32_t *nNonce_p = (uint32_t *)(pdata + 12);
uint32_t *nNonce_p = (uint32_t *)(pdata + 76);
uint32_t m_midstate[8], m_w[16], m_w1[16];
__m128i m_4w[64] __attribute__ ((aligned (0x100)));
__m128i m_4hash[64] __attribute__ ((aligned (0x100)));
@ -65,6 +65,8 @@ int scanhash_sse2_64(int thr_id, const unsigned char *pmidstate, @@ -65,6 +65,8 @@ int scanhash_sse2_64(int thr_id, const unsigned char *pmidstate,
__m128i offset;
int i;
pdata += 64;
work_restart[thr_id].restart = 0;
/* For debugging */
@ -114,19 +116,20 @@ int scanhash_sse2_64(int thr_id, const unsigned char *pmidstate, @@ -114,19 +116,20 @@ int scanhash_sse2_64(int thr_id, const unsigned char *pmidstate,
}
if (fulltest(phash, ptarget)) {
*nHashesDone = nonce;
*nNonce_p = nonce + j;
return nonce + j;
nonce += j;
*last_nonce = nonce + 1;
*nNonce_p = nonce;
return true;
}
}
nonce += 4;
if (unlikely((nonce >= max_nonce) || work_restart[thr_id].restart))
{
*nHashesDone = nonce;
return -1;
*last_nonce = nonce;
return false;
}
nonce += 4;
}
}

25
sha256_sse2_i386.c

@ -50,14 +50,14 @@ const uint32_t sha256_32init[8]__attribute__((aligned(0x100))) = @@ -50,14 +50,14 @@ const uint32_t sha256_32init[8]__attribute__((aligned(0x100))) =
__m128i g_4sha256_k[64];
__m128i sha256_consts_m128i[64]__attribute__((aligned(0x1000)));
int scanhash_sse2_32(int thr_id, const unsigned char *pmidstate,
bool scanhash_sse2_32(int thr_id, const unsigned char *pmidstate,
unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, unsigned long *nHashesDone,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t nonce)
{
uint32_t *nNonce_p = (uint32_t *)(pdata + 12);
uint32_t *nNonce_p = (uint32_t *)(pdata + 76);
uint32_t m_midstate[8], m_w[16], m_w1[16];
__m128i m_4w[64] __attribute__ ((aligned (0x100)));
__m128i m_4hash[64] __attribute__ ((aligned (0x100)));
@ -65,6 +65,8 @@ int scanhash_sse2_32(int thr_id, const unsigned char *pmidstate, @@ -65,6 +65,8 @@ int scanhash_sse2_32(int thr_id, const unsigned char *pmidstate,
__m128i offset;
int i;
pdata += 64;
work_restart[thr_id].restart = 0;
/* For debugging */
@ -116,19 +118,20 @@ int scanhash_sse2_32(int thr_id, const unsigned char *pmidstate, @@ -116,19 +118,20 @@ int scanhash_sse2_32(int thr_id, const unsigned char *pmidstate,
}
if (fulltest(phash, ptarget)) {
*nHashesDone = nonce;
*nNonce_p = nonce + j;
return nonce + j;
nonce += j;
*last_nonce = nonce;
*nNonce_p = nonce;
return true;
}
}
if (unlikely((nonce >= max_nonce) || work_restart[thr_id].restart)) {
*last_nonce = nonce;
return false;
}
nonce += 4;
if (unlikely((nonce >= max_nonce) || work_restart[thr_id].restart))
{
*nHashesDone = nonce;
return -1;
}
}
}

23
sha256_sse4_amd64.c

@ -49,19 +49,21 @@ static uint32_t g_sha256_hinit[8] = @@ -49,19 +49,21 @@ static uint32_t g_sha256_hinit[8] =
__m128i g_4sha256_k[64];
int scanhash_sse4_64(int thr_id, const unsigned char *pmidstate,
bool scanhash_sse4_64(int thr_id, const unsigned char *pmidstate,
unsigned char *pdata,
unsigned char *phash1, unsigned char *phash,
const unsigned char *ptarget,
uint32_t max_nonce, unsigned long *nHashesDone,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t nonce)
{
uint32_t *nNonce_p = (uint32_t *)(pdata + 12);
uint32_t *nNonce_p = (uint32_t *)(pdata + 76);
uint32_t m_midstate[8], m_w[16], m_w1[16];
__m128i m_4w[64], m_4hash[64], m_4hash1[64];
__m128i offset;
int i;
pdata += 64;
work_restart[thr_id].restart = 0;
/* For debugging */
@ -113,19 +115,20 @@ int scanhash_sse4_64(int thr_id, const unsigned char *pmidstate, @@ -113,19 +115,20 @@ int scanhash_sse4_64(int thr_id, const unsigned char *pmidstate,
}
if (fulltest(phash, ptarget)) {
*nHashesDone = nonce;
*nNonce_p = nonce + j;
return nonce + j;
nonce += j;
*last_nonce = nonce;
*nNonce_p = nonce;
return true;
}
}
nonce += 4;
if (unlikely((nonce >= max_nonce) || work_restart[thr_id].restart))
{
*nHashesDone = nonce;
return -1;
*last_nonce = nonce;
return false;
}
nonce += 4;
}
}

10
sha256_via.c

@ -19,9 +19,11 @@ static void via_sha256(void *hash, void *buf, unsigned len) @@ -19,9 +19,11 @@ static void via_sha256(void *hash, void *buf, unsigned len)
:"memory");
}
bool scanhash_via(int thr_id, unsigned char *data_inout,
bool scanhash_via(int thr_id, const unsigned char *pmidstate,
unsigned char *data_inout,
unsigned char *phash1, unsigned char *phash,
const unsigned char *target,
uint32_t max_nonce, unsigned long *hashes_done,
uint32_t max_nonce, uint32_t *last_nonce,
uint32_t n)
{
unsigned char data[128] __attribute__((aligned(128)));
@ -70,12 +72,12 @@ bool scanhash_via(int thr_id, unsigned char *data_inout, @@ -70,12 +72,12 @@ bool scanhash_via(int thr_id, unsigned char *data_inout,
dout32[i] = swab32(data32[i]);
}
*hashes_done = n;
*last_nonce = n;
return true;
}
if ((n >= max_nonce) || work_restart[thr_id].restart) {
*hashes_done = n;
*last_nonce = n;
return false;
}
}

Loading…
Cancel
Save