mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-11 07:17:58 +00:00
Use a 64 bit unsigned integer on the diff target to generate the hex target.
This commit is contained in:
parent
a533f106fd
commit
ca962ee58b
17
cgminer.c
17
cgminer.c
@ -4533,18 +4533,13 @@ static void gen_hash(unsigned char *data, unsigned char *hash, int len)
|
|||||||
static void set_work_target(struct work *work, int diff)
|
static void set_work_target(struct work *work, int diff)
|
||||||
{
|
{
|
||||||
unsigned char rtarget[33], target[33];
|
unsigned char rtarget[33], target[33];
|
||||||
uint8_t *data8;
|
uint64_t *data64, h64;
|
||||||
int i, j;
|
|
||||||
|
|
||||||
/* Scale to any diff by setting number of bits according to diff */
|
hex2bin(rtarget, "00000000ffff0000000000000000000000000000000000000000000000000000", 32);
|
||||||
hex2bin(rtarget, "00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff", 32);
|
data64 = (uint64_t *)(rtarget + 4);
|
||||||
data8 = (uint8_t *)(rtarget + 4);
|
h64 = be64toh(*data64);
|
||||||
for (i = 1, j = 0; i < diff; i++, j++) {
|
h64 /= (uint64_t)diff;
|
||||||
int byte = j / 8;
|
*data64 = htobe64(h64);
|
||||||
int bit = j % 8;
|
|
||||||
|
|
||||||
data8[byte] &= ~(128 >> bit);
|
|
||||||
}
|
|
||||||
swab256(target, rtarget);
|
swab256(target, rtarget);
|
||||||
if (opt_debug) {
|
if (opt_debug) {
|
||||||
char *htarget = bin2hex(target, 32);
|
char *htarget = bin2hex(target, 32);
|
||||||
|
Loading…
Reference in New Issue
Block a user