mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Pass max-nonce as arg to each sha256 algo.
Should be an equivalent transformation, with no behavior changes.
This commit is contained in:
parent
f570ffcf75
commit
0b67740707
13
cpu-miner.c
13
cpu-miner.c
@ -301,7 +301,8 @@ static void *miner_thread(void *thr_id_int)
|
|||||||
switch (opt_algo) {
|
switch (opt_algo) {
|
||||||
case ALGO_C:
|
case ALGO_C:
|
||||||
rc = scanhash_c(work.midstate, work.data + 64,
|
rc = scanhash_c(work.midstate, work.data + 64,
|
||||||
work.hash1, work.hash, &hashes_done);
|
work.hash1, work.hash,
|
||||||
|
0xffffff, &hashes_done);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef WANT_SSE2_4WAY
|
#ifdef WANT_SSE2_4WAY
|
||||||
@ -309,7 +310,7 @@ static void *miner_thread(void *thr_id_int)
|
|||||||
unsigned int rc4 =
|
unsigned int rc4 =
|
||||||
ScanHash_4WaySSE2(work.midstate, work.data + 64,
|
ScanHash_4WaySSE2(work.midstate, work.data + 64,
|
||||||
work.hash1, work.hash,
|
work.hash1, work.hash,
|
||||||
&hashes_done);
|
0xffffff, &hashes_done);
|
||||||
rc = (rc4 == -1) ? false : true;
|
rc = (rc4 == -1) ? false : true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@ -317,18 +318,20 @@ static void *miner_thread(void *thr_id_int)
|
|||||||
|
|
||||||
#ifdef WANT_VIA_PADLOCK
|
#ifdef WANT_VIA_PADLOCK
|
||||||
case ALGO_VIA:
|
case ALGO_VIA:
|
||||||
rc = scanhash_via(work.data, &hashes_done);
|
rc = scanhash_via(work.data, 0xffffff, &hashes_done);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
case ALGO_CRYPTOPP:
|
case ALGO_CRYPTOPP:
|
||||||
rc = scanhash_cryptopp(work.midstate, work.data + 64,
|
rc = scanhash_cryptopp(work.midstate, work.data + 64,
|
||||||
work.hash1, work.hash, &hashes_done);
|
work.hash1, work.hash,
|
||||||
|
0xffffff, &hashes_done);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#ifdef WANT_CRYPTOPP_ASM32
|
#ifdef WANT_CRYPTOPP_ASM32
|
||||||
case ALGO_CRYPTOPP_ASM32:
|
case ALGO_CRYPTOPP_ASM32:
|
||||||
rc = scanhash_asm32(work.midstate, work.data + 64,
|
rc = scanhash_asm32(work.midstate, work.data + 64,
|
||||||
work.hash1, work.hash, &hashes_done);
|
work.hash1, work.hash,
|
||||||
|
0xffffff, &hashes_done);
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
11
miner.h
11
miner.h
@ -37,19 +37,20 @@ extern bool hex2bin(unsigned char *p, const char *hexstr, size_t len);
|
|||||||
|
|
||||||
extern unsigned int ScanHash_4WaySSE2(const unsigned char *pmidstate,
|
extern unsigned int ScanHash_4WaySSE2(const unsigned char *pmidstate,
|
||||||
unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
|
unsigned char *pdata, unsigned char *phash1, unsigned char *phash,
|
||||||
unsigned long *nHashesDone);
|
uint32_t max_nonce, unsigned long *nHashesDone);
|
||||||
|
|
||||||
extern bool scanhash_via(unsigned char *data_inout, unsigned long *hashes_done);
|
extern bool scanhash_via(unsigned char *data_inout,
|
||||||
|
uint32_t max_nonce, unsigned long *hashes_done);
|
||||||
|
|
||||||
extern bool scanhash_c(const unsigned char *midstate, unsigned char *data,
|
extern bool scanhash_c(const unsigned char *midstate, unsigned char *data,
|
||||||
unsigned char *hash1, unsigned char *hash,
|
unsigned char *hash1, unsigned char *hash,
|
||||||
unsigned long *hashes_done);
|
uint32_t max_nonce, unsigned long *hashes_done);
|
||||||
extern bool scanhash_cryptopp(const unsigned char *midstate,unsigned char *data,
|
extern bool scanhash_cryptopp(const unsigned char *midstate,unsigned char *data,
|
||||||
unsigned char *hash1, unsigned char *hash,
|
unsigned char *hash1, unsigned char *hash,
|
||||||
unsigned long *hashes_done);
|
uint32_t max_nonce, unsigned long *hashes_done);
|
||||||
extern bool scanhash_asm32(const unsigned char *midstate,unsigned char *data,
|
extern bool scanhash_asm32(const unsigned char *midstate,unsigned char *data,
|
||||||
unsigned char *hash1, unsigned char *hash,
|
unsigned char *hash1, unsigned char *hash,
|
||||||
unsigned long *hashes_done);
|
uint32_t max_nonce, unsigned long *hashes_done);
|
||||||
|
|
||||||
extern int
|
extern int
|
||||||
timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
|
timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
|
||||||
|
@ -99,7 +99,8 @@ static const unsigned int pSHA256InitState[8] =
|
|||||||
|
|
||||||
|
|
||||||
unsigned int ScanHash_4WaySSE2(const unsigned char *pmidstate, unsigned char *pdata,
|
unsigned int ScanHash_4WaySSE2(const unsigned char *pmidstate, unsigned char *pdata,
|
||||||
unsigned char *phash1, unsigned char *phash, unsigned long *nHashesDone)
|
unsigned char *phash1, unsigned char *phash,
|
||||||
|
uint32_t max_nonce, unsigned long *nHashesDone)
|
||||||
{
|
{
|
||||||
unsigned int *nNonce_p = (unsigned int*)(pdata + 12);
|
unsigned int *nNonce_p = (unsigned int*)(pdata + 12);
|
||||||
unsigned int nonce = 0;
|
unsigned int nonce = 0;
|
||||||
@ -128,9 +129,9 @@ unsigned int ScanHash_4WaySSE2(const unsigned char *pmidstate, unsigned char *pd
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((nonce & 0xffffff) == 0)
|
if (nonce >= max_nonce)
|
||||||
{
|
{
|
||||||
*nHashesDone = 0xffffff+1;
|
*nHashesDone = nonce;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +93,7 @@ static void runhash(void *state, const void *input, const void *init)
|
|||||||
/* suspiciously similar to ScanHash* from bitcoin */
|
/* suspiciously similar to ScanHash* from bitcoin */
|
||||||
bool scanhash_cryptopp(const unsigned char *midstate, unsigned char *data,
|
bool scanhash_cryptopp(const unsigned char *midstate, unsigned char *data,
|
||||||
unsigned char *hash1, unsigned char *hash,
|
unsigned char *hash1, unsigned char *hash,
|
||||||
unsigned long *hashes_done)
|
uint32_t max_nonce, unsigned long *hashes_done)
|
||||||
{
|
{
|
||||||
uint32_t *hash32 = (uint32_t *) hash;
|
uint32_t *hash32 = (uint32_t *) hash;
|
||||||
uint32_t *nonce = (uint32_t *)(data + 12);
|
uint32_t *nonce = (uint32_t *)(data + 12);
|
||||||
@ -122,7 +122,7 @@ bool scanhash_cryptopp(const unsigned char *midstate, unsigned char *data,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((n & 0xffffff) == 0) {
|
if (n >= max_nonce) {
|
||||||
if (opt_debug)
|
if (opt_debug)
|
||||||
fprintf(stderr, "DBG: end of nonce range\n");
|
fprintf(stderr, "DBG: end of nonce range\n");
|
||||||
*hashes_done = stat_ctr;
|
*hashes_done = stat_ctr;
|
||||||
@ -584,7 +584,7 @@ static void runhash32(void *state, const void *input, const void *init)
|
|||||||
/* suspiciously similar to ScanHash* from bitcoin */
|
/* suspiciously similar to ScanHash* from bitcoin */
|
||||||
bool scanhash_asm32(const unsigned char *midstate, unsigned char *data,
|
bool scanhash_asm32(const unsigned char *midstate, unsigned char *data,
|
||||||
unsigned char *hash1, unsigned char *hash,
|
unsigned char *hash1, unsigned char *hash,
|
||||||
unsigned long *hashes_done)
|
uint32_t max_nonce, unsigned long *hashes_done)
|
||||||
{
|
{
|
||||||
uint32_t *hash32 = (uint32_t *) hash;
|
uint32_t *hash32 = (uint32_t *) hash;
|
||||||
uint32_t *nonce = (uint32_t *)(data + 12);
|
uint32_t *nonce = (uint32_t *)(data + 12);
|
||||||
@ -613,7 +613,7 @@ bool scanhash_asm32(const unsigned char *midstate, unsigned char *data,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((n & 0xffffff) == 0) {
|
if (n >= max_nonce) {
|
||||||
if (opt_debug)
|
if (opt_debug)
|
||||||
fprintf(stderr, "DBG: end of nonce range\n");
|
fprintf(stderr, "DBG: end of nonce range\n");
|
||||||
*hashes_done = stat_ctr;
|
*hashes_done = stat_ctr;
|
||||||
|
@ -239,7 +239,7 @@ const uint32_t sha256_init_state[8] = {
|
|||||||
/* suspiciously similar to ScanHash* from bitcoin */
|
/* suspiciously similar to ScanHash* from bitcoin */
|
||||||
bool scanhash_c(const unsigned char *midstate, unsigned char *data,
|
bool scanhash_c(const unsigned char *midstate, unsigned char *data,
|
||||||
unsigned char *hash1, unsigned char *hash,
|
unsigned char *hash1, unsigned char *hash,
|
||||||
unsigned long *hashes_done)
|
uint32_t max_nonce, unsigned long *hashes_done)
|
||||||
{
|
{
|
||||||
uint32_t *hash32 = (uint32_t *) hash;
|
uint32_t *hash32 = (uint32_t *) hash;
|
||||||
uint32_t *nonce = (uint32_t *)(data + 12);
|
uint32_t *nonce = (uint32_t *)(data + 12);
|
||||||
@ -268,7 +268,7 @@ bool scanhash_c(const unsigned char *midstate, unsigned char *data,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((n & 0xffffff) == 0) {
|
if (n >= max_nonce) {
|
||||||
if (opt_debug)
|
if (opt_debug)
|
||||||
fprintf(stderr, "DBG: end of nonce range\n");
|
fprintf(stderr, "DBG: end of nonce range\n");
|
||||||
*hashes_done = stat_ctr;
|
*hashes_done = stat_ctr;
|
||||||
|
@ -17,7 +17,8 @@ static void via_sha256(void *hash, void *buf, unsigned len)
|
|||||||
:"memory");
|
:"memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
bool scanhash_via(unsigned char *data_inout, unsigned long *hashes_done)
|
bool scanhash_via(unsigned char *data_inout,
|
||||||
|
uint32_t max_nonce, unsigned long *hashes_done)
|
||||||
{
|
{
|
||||||
unsigned char data[128] __attribute__((aligned(128)));
|
unsigned char data[128] __attribute__((aligned(128)));
|
||||||
unsigned char tmp_hash[32] __attribute__((aligned(128)));
|
unsigned char tmp_hash[32] __attribute__((aligned(128)));
|
||||||
@ -76,7 +77,7 @@ bool scanhash_via(unsigned char *data_inout, unsigned long *hashes_done)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((n & 0xffffff) == 0) {
|
if (n >= max_nonce) {
|
||||||
if (opt_debug)
|
if (opt_debug)
|
||||||
fprintf(stderr, "DBG: end of nonce range\n");
|
fprintf(stderr, "DBG: end of nonce range\n");
|
||||||
*hashes_done = stat_ctr;
|
*hashes_done = stat_ctr;
|
||||||
|
Loading…
Reference in New Issue
Block a user