mirror of
https://github.com/GOSTSec/ccminer
synced 2025-01-24 05:24:16 +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);
|
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)
|
extern "C" double bn_hash_target_ratio(uint32_t* hash, uint32_t* target)
|
||||||
{
|
{
|
||||||
unsigned char* uc;
|
|
||||||
double dhash;
|
double dhash;
|
||||||
|
|
||||||
if (!opt_showdiff)
|
if (!opt_showdiff)
|
||||||
@ -47,6 +48,26 @@ extern "C" double bn_hash_target_ratio(uint32_t* hash, uint32_t* target)
|
|||||||
else
|
else
|
||||||
return dhash;
|
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
|
// store ratio in work struct
|
||||||
extern "C" void bn_store_hash_target_ratio(uint32_t* hash, uint32_t* target, struct work* work)
|
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->shareratio = bn_hash_target_ratio(hash, target);
|
||||||
work->sharediff = work->targetdiff * work->shareratio;
|
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)
|
static void calc_network_diff(struct work *work)
|
||||||
{
|
{
|
||||||
// sample for diff 43.281 : 1c05ea29
|
// sample for diff 43.281 : 1c05ea29
|
||||||
uchar rtarget[48] = { 0 };
|
|
||||||
uint64_t *data64, d64;
|
|
||||||
// todo: endian reversed on longpoll could be zr5 specific...
|
// todo: endian reversed on longpoll could be zr5 specific...
|
||||||
uint32_t nbits = have_longpoll ? work->data[18] : swab32(work->data[18]);
|
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);
|
uint32_t bits = (nbits & 0xffffff);
|
||||||
int shfb = 8 * (26 - (shift - 3));
|
int16_t shift = (swab32(nbits) & 0xff); // 0x1c = 28
|
||||||
|
|
||||||
#if 1
|
#if 1
|
||||||
uint64_t diffone = 0x0000FFFF00000000ull;
|
uint64_t diffone = 0x0000FFFF00000000ull;
|
||||||
double d = (double)0x0000ffff / (double)bits;
|
double d = (double)0x0000ffff / (double)bits;
|
||||||
for (int m=shift; m < 29; m++) d *= 256.0;
|
for (int m=shift; m < 29; m++) d *= 256.0;
|
||||||
for (int m=29; m < shift; m++) d /= 256.0;
|
for (int m=29; m < shift; m++) d /= 256.0;
|
||||||
if (opt_debug_diff)
|
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;
|
net_diff = d;
|
||||||
return;
|
return;
|
||||||
#else
|
#else
|
||||||
|
uchar rtarget[48] = { 0 };
|
||||||
|
uint64_t *data64, d64;
|
||||||
uint64_t diffone = 0xFFFF000000000000ull; //swab64(0xFFFFull);
|
uint64_t diffone = 0xFFFF000000000000ull; //swab64(0xFFFFull);
|
||||||
|
int shfb = 8 * (26 - (shift - 3));
|
||||||
|
|
||||||
switch (opt_algo) {
|
switch (opt_algo) {
|
||||||
case ALGO_QUARK:
|
case ALGO_QUARK:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user