Browse Source

Display proof-of-work hash when one is discovered

nfactor-troky
Jeff Garzik 14 years ago committed by Jeff Garzik
parent
commit
c68ffb30dd
  1. 17
      miner.h
  2. 3
      sha256_4way.c
  3. 16
      sha256_cryptopp.c
  4. 8
      sha256_generic.c
  5. 8
      sha256_via.c
  6. 11
      util.c

17
miner.h

@ -27,6 +27,21 @@ static inline uint32_t swab32(uint32_t v) @@ -27,6 +27,21 @@ static inline uint32_t swab32(uint32_t v)
return __builtin_bswap32(v);
}
static inline void swap256(void *dest_p, const void *src_p)
{
uint32_t *dest = dest_p;
const uint32_t *src = src_p;
dest[0] = src[7];
dest[1] = src[6];
dest[2] = src[5];
dest[3] = src[4];
dest[4] = src[3];
dest[5] = src[2];
dest[6] = src[1];
dest[7] = src[0];
}
extern bool opt_debug;
extern bool opt_protocol;
extern const uint32_t sha256_init_state[];
@ -55,4 +70,6 @@ extern bool scanhash_asm32(const unsigned char *midstate,unsigned char *data, @@ -55,4 +70,6 @@ extern bool scanhash_asm32(const unsigned char *midstate,unsigned char *data,
extern int
timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y);
extern void print_pow(const unsigned char *hash);
#endif /* __MINER_H__ */

3
sha256_4way.c

@ -123,6 +123,9 @@ unsigned int ScanHash_4WaySSE2(const unsigned char *pmidstate, unsigned char *pd @@ -123,6 +123,9 @@ unsigned int ScanHash_4WaySSE2(const unsigned char *pmidstate, unsigned char *pd
for (i = 0; i < 32/4; i++)
((unsigned int*)phash)[i] = thash[i][j];
print_pow(phash);
*nHashesDone = nonce;
*nNonce_p = nonce + j;
return nonce + j;

16
sha256_cryptopp.c

@ -110,13 +110,7 @@ bool scanhash_cryptopp(const unsigned char *midstate, unsigned char *data, @@ -110,13 +110,7 @@ bool scanhash_cryptopp(const unsigned char *midstate, unsigned char *data,
stat_ctr++;
if (hash32[7] == 0) {
char *hexstr;
hexstr = bin2hex(hash, 32);
fprintf(stderr,
"DBG: found zeroes in hash:\n%s\n",
hexstr);
free(hexstr);
print_pow(hash);
*hashes_done = stat_ctr;
return true;
@ -601,13 +595,7 @@ bool scanhash_asm32(const unsigned char *midstate, unsigned char *data, @@ -601,13 +595,7 @@ bool scanhash_asm32(const unsigned char *midstate, unsigned char *data,
stat_ctr++;
if (hash32[7] == 0) {
char *hexstr;
hexstr = bin2hex(hash, 32);
fprintf(stderr,
"DBG: found zeroes in hash:\n%s\n",
hexstr);
free(hexstr);
print_pow(hash);
*hashes_done = stat_ctr;
return true;

8
sha256_generic.c

@ -256,13 +256,7 @@ bool scanhash_c(const unsigned char *midstate, unsigned char *data, @@ -256,13 +256,7 @@ bool scanhash_c(const unsigned char *midstate, unsigned char *data,
stat_ctr++;
if (hash32[7] == 0) {
char *hexstr;
hexstr = bin2hex(hash, 32);
fprintf(stderr,
"DBG: found zeroes in hash:\n%s\n",
hexstr);
free(hexstr);
print_pow(hash);
*hashes_done = stat_ctr;
return true;

8
sha256_via.c

@ -57,13 +57,7 @@ bool scanhash_via(unsigned char *data_inout, @@ -57,13 +57,7 @@ bool scanhash_via(unsigned char *data_inout,
stat_ctr++;
if (hash32[7] == 0) {
char *hexstr;
hexstr = bin2hex(tmp_hash, 32);
fprintf(stderr,
"DBG: found zeroes in hash:\n%s\n",
hexstr);
free(hexstr);
print_pow(tmp_hash);
/* swap nonce'd data back into original storage area;
* TODO: only swap back the nonce, rather than all data

11
util.c

@ -255,3 +255,14 @@ timeval_subtract ( @@ -255,3 +255,14 @@ timeval_subtract (
return x->tv_sec < y->tv_sec;
}
void print_pow(const unsigned char *hash)
{
char *hexstr;
unsigned char hash_swap[32];
swap256(hash_swap, hash);
hexstr = bin2hex(hash_swap, 32);
fprintf(stderr, "PoW found: %s\n", hexstr);
free(hexstr);
}

Loading…
Cancel
Save