|
|
|
@ -25,9 +25,10 @@ extern "C" void bn_nbits_to_uchar(const uint32_t nBits, unsigned char *target)
@@ -25,9 +25,10 @@ extern "C" void bn_nbits_to_uchar(const uint32_t nBits, unsigned char *target)
|
|
|
|
|
hex2bin(target, buff, 32); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// unused, but should allow more than 256bits targets
|
|
|
|
|
#if 0 |
|
|
|
|
extern "C" double bn_hash_target_ratio(uint32_t* hash, uint32_t* target) |
|
|
|
|
{ |
|
|
|
|
unsigned char* uc; |
|
|
|
|
double dhash; |
|
|
|
|
|
|
|
|
|
if (!opt_showdiff) |
|
|
|
@ -47,6 +48,26 @@ extern "C" double bn_hash_target_ratio(uint32_t* hash, uint32_t* target)
@@ -47,6 +48,26 @@ extern "C" double bn_hash_target_ratio(uint32_t* hash, uint32_t* target)
|
|
|
|
|
else |
|
|
|
|
return dhash; |
|
|
|
|
} |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// compute the diff ratio between a found hash and the target
|
|
|
|
|
extern "C" double bn_hash_target_ratio(uint32_t* hash, uint32_t* target) |
|
|
|
|
{ |
|
|
|
|
uint256 h, t; |
|
|
|
|
double dhash; |
|
|
|
|
|
|
|
|
|
if (!opt_showdiff) |
|
|
|
|
return 0.0; |
|
|
|
|
|
|
|
|
|
memcpy(&t, (void*) target, 32); |
|
|
|
|
memcpy(&h, (void*) hash, 32); |
|
|
|
|
|
|
|
|
|
dhash = h.getdouble(); |
|
|
|
|
if (dhash > 0.) |
|
|
|
|
return t.getdouble() / dhash; |
|
|
|
|
else |
|
|
|
|
return dhash; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// store ratio in work struct
|
|
|
|
|
extern "C" void bn_store_hash_target_ratio(uint32_t* hash, uint32_t* target, struct work* work) |
|
|
|
@ -56,4 +77,4 @@ extern "C" void bn_store_hash_target_ratio(uint32_t* hash, uint32_t* target, str
@@ -56,4 +77,4 @@ extern "C" void bn_store_hash_target_ratio(uint32_t* hash, uint32_t* target, str
|
|
|
|
|
work->shareratio = bn_hash_target_ratio(hash, target); |
|
|
|
|
work->sharediff = work->targetdiff * work->shareratio; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |