]> Git Repo - cpuminer-multi.git/blame - uint256.cpp
blake2b algo
[cpuminer-multi.git] / uint256.cpp
CommitLineData
78a3ef92
TP
1#include "uint256.h"
2
3#ifdef __cplusplus
4extern "C"{
5#endif
6
7#include "miner.h"
8
9// compute the diff ratio between a found hash and the target
10double 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
e67ae95f
TP
28// store the share ratio in work struct
29void work_set_target_ratio(struct work* work, uint32_t* hash)
78a3ef92
TP
30{
31 // only if the option is enabled (to reduce cpu usage)
e67ae95f
TP
32 if (opt_showdiff && work) {
33 work->shareratio = hash_target_ratio(hash, work->target);
78a3ef92 34 work->sharediff = work->targetdiff * work->shareratio;
e67ae95f
TP
35 if (opt_debug)
36 applog(LOG_DEBUG, "share diff %.5f (%.1fx)", work->sharediff, work->shareratio);
78a3ef92
TP
37 }
38}
39
40#ifdef __cplusplus
41}
42#endif
This page took 0.029638 seconds and 4 git commands to generate.