|
|
@ -5922,38 +5922,23 @@ static void gen_hash(unsigned char *data, unsigned char *hash, int len) |
|
|
|
sha256(hash1, 32, hash); |
|
|
|
sha256(hash1, 32, hash); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Diff 1 is a 256 bit unsigned integer of
|
|
|
|
|
|
|
|
* 0x00000000ffff0000000000000000000000000000000000000000000000000000 |
|
|
|
|
|
|
|
* so we use a big endian 64 bit unsigned integer centred on the 5th byte to |
|
|
|
|
|
|
|
* cover a huge range of difficulty targets, though not all 256 bits' worth */ |
|
|
|
|
|
|
|
void set_target(unsigned char *dest_target, double diff) |
|
|
|
void set_target(unsigned char *dest_target, double diff) |
|
|
|
{ |
|
|
|
{ |
|
|
|
unsigned char target[32]; |
|
|
|
unsigned char target[32], rtarget[32]; |
|
|
|
uint64_t *data64, h64; |
|
|
|
uint64_t *data64, h64; |
|
|
|
double d64; |
|
|
|
double d64; |
|
|
|
|
|
|
|
|
|
|
|
d64 = diffone; |
|
|
|
if (opt_scrypt) |
|
|
|
|
|
|
|
d64 = 0xFFFF00000000ull; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
d64 = 0xFFFF0000ull; |
|
|
|
d64 /= diff; |
|
|
|
d64 /= diff; |
|
|
|
h64 = d64; |
|
|
|
h64 = d64; |
|
|
|
|
|
|
|
|
|
|
|
memset(target, 0, 32); |
|
|
|
memset(rtarget, 0xFF, 32); |
|
|
|
if (h64) { |
|
|
|
data64 = (uint64_t *)rtarget; |
|
|
|
unsigned char rtarget[32]; |
|
|
|
*data64 = htobe64(h64); |
|
|
|
|
|
|
|
swab256(target, rtarget); |
|
|
|
memset(rtarget, 0, 32); |
|
|
|
|
|
|
|
if (opt_scrypt) |
|
|
|
|
|
|
|
data64 = (uint64_t *)(rtarget + 2); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
data64 = (uint64_t *)(rtarget + 4); |
|
|
|
|
|
|
|
*data64 = htobe64(h64); |
|
|
|
|
|
|
|
swab256(target, rtarget); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
/* Support for the classic all FFs just-below-1 diff */ |
|
|
|
|
|
|
|
if (opt_scrypt) |
|
|
|
|
|
|
|
memset(target, 0xff, 30); |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
memset(target, 0xff, 28); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (opt_debug) { |
|
|
|
if (opt_debug) { |
|
|
|
char *htarget = bin2hex(target, 32); |
|
|
|
char *htarget = bin2hex(target, 32); |
|
|
|