Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
litecoincash-project
GitHub Repository: litecoincash-project/cpuminer-multi
Path: blob/master/uint256.cpp
548 views
1
#include "uint256.h"
2
3
#ifdef __cplusplus
4
extern "C"{
5
#endif
6
7
#include "miner.h"
8
9
// compute the diff ratio between a found hash and the target
10
double hash_target_ratio(uint32_t* hash, uint32_t* target)
11
{
12
uint256 h, t;
13
double dhash;
14
15
if (!opt_showdiff)
16
return 0.0;
17
18
memcpy(&t, (void*) target, 32);
19
memcpy(&h, (void*) hash, 32);
20
21
dhash = h.getdouble();
22
if (dhash > 0.)
23
return t.getdouble() / dhash;
24
else
25
return dhash;
26
}
27
28
// store the share ratio in work struct
29
void work_set_target_ratio(struct work* work, uint32_t* hash)
30
{
31
// only if the option is enabled (to reduce cpu usage)
32
if (opt_showdiff && work) {
33
work->shareratio = hash_target_ratio(hash, work->target);
34
work->sharediff = work->targetdiff * work->shareratio;
35
if (opt_debug)
36
applog(LOG_DEBUG, "share diff %.5f (%.1fx)", work->sharediff, work->shareratio);
37
}
38
}
39
40
#ifdef __cplusplus
41
}
42
#endif
43
44