mirror of
https://github.com/GOSTSec/ccminer
synced 2025-01-08 22:07:56 +00:00
diff: cleanup after windows test
This commit is contained in:
parent
5308898d1c
commit
fade2b74b5
25
bignum.cpp
25
bignum.cpp
@ -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)
|
||||
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
|
||||
work->shareratio = bn_hash_target_ratio(hash, target);
|
||||
work->sharediff = work->targetdiff * work->shareratio;
|
||||
}
|
||||
}
|
||||
}
|
11
ccminer.cpp
11
ccminer.cpp
@ -604,25 +604,24 @@ static bool jobj_binary(const json_t *obj, const char *key,
|
||||
static void calc_network_diff(struct work *work)
|
||||
{
|
||||
// sample for diff 43.281 : 1c05ea29
|
||||
uchar rtarget[48] = { 0 };
|
||||
uint64_t *data64, d64;
|
||||
// todo: endian reversed on longpoll could be zr5 specific...
|
||||
uint32_t nbits = have_longpoll ? work->data[18] : swab32(work->data[18]);
|
||||
uint32_t shift = (swab32(nbits) & 0xff); // 0x1c = 28
|
||||
uint32_t bits = (nbits & 0xffffff);
|
||||
int shfb = 8 * (26 - (shift - 3));
|
||||
|
||||
int16_t shift = (swab32(nbits) & 0xff); // 0x1c = 28
|
||||
#if 1
|
||||
uint64_t diffone = 0x0000FFFF00000000ull;
|
||||
double d = (double)0x0000ffff / (double)bits;
|
||||
for (int m=shift; m < 29; m++) d *= 256.0;
|
||||
for (int m=29; m < shift; m++) d /= 256.0;
|
||||
if (opt_debug_diff)
|
||||
applog(LOG_DEBUG, "diff: %f -> shift %u, bits %08x, shfb %d", d, shift, bits, shfb);
|
||||
applog(LOG_DEBUG, "net diff: %f -> shift %u, bits %08x", d, shift, bits);
|
||||
net_diff = d;
|
||||
return;
|
||||
#else
|
||||
uchar rtarget[48] = { 0 };
|
||||
uint64_t *data64, d64;
|
||||
uint64_t diffone = 0xFFFF000000000000ull; //swab64(0xFFFFull);
|
||||
int shfb = 8 * (26 - (shift - 3));
|
||||
|
||||
switch (opt_algo) {
|
||||
case ALGO_QUARK:
|
||||
|
Loading…
Reference in New Issue
Block a user