diff options
author | Jeff Garzik <jeff@garzik.org> | 2011-02-02 18:47:04 -0500 |
---|---|---|
committer | Jeff Garzik <jgarzik@redhat.com> | 2011-02-02 18:47:04 -0500 |
commit | c68ffb30dd17b32f69665af18b72687875770972 (patch) | |
tree | 748110c309233117b7f26bd4dc575a2904266aba | |
parent | 453101d9e9f8b7408ca645dd174aa3e8af1d87ac (diff) |
Display proof-of-work hash when one is discovered
-rw-r--r-- | miner.h | 17 | ||||
-rw-r--r-- | sha256_4way.c | 3 | ||||
-rw-r--r-- | sha256_cryptopp.c | 16 | ||||
-rw-r--r-- | sha256_generic.c | 8 | ||||
-rw-r--r-- | sha256_via.c | 8 | ||||
-rw-r--r-- | util.c | 11 |
6 files changed, 35 insertions, 28 deletions
@@ -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, extern int timeval_subtract (struct timeval *result, struct timeval *x, struct timeval *y); +extern void print_pow(const unsigned char *hash); + #endif /* __MINER_H__ */ diff --git a/sha256_4way.c b/sha256_4way.c index bdc4c23..556a07a 100644 --- a/sha256_4way.c +++ b/sha256_4way.c @@ -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; diff --git a/sha256_cryptopp.c b/sha256_cryptopp.c index 1535b6b..4ada480 100644 --- a/sha256_cryptopp.c +++ b/sha256_cryptopp.c @@ -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, 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; diff --git a/sha256_generic.c b/sha256_generic.c index 8817d92..91fbbcf 100644 --- a/sha256_generic.c +++ b/sha256_generic.c @@ -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; diff --git a/sha256_via.c b/sha256_via.c index 94576a4..011d854 100644 --- a/sha256_via.c +++ b/sha256_via.c @@ -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 @@ -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); +} + |