mirror of
https://github.com/GOSTSec/sgminer
synced 2025-01-25 22:14:36 +00:00
Support for fractional diffs and the classic just-below-1 share all FFs diff target.
This commit is contained in:
parent
97059e4c29
commit
b3864d1a94
24
cgminer.c
24
cgminer.c
@ -5078,17 +5078,27 @@ static void gen_hash(unsigned char *data, unsigned char *hash, int len)
|
|||||||
* 0x00000000ffff0000000000000000000000000000000000000000000000000000
|
* 0x00000000ffff0000000000000000000000000000000000000000000000000000
|
||||||
* so we use a big endian 64 bit unsigned integer centred on the 5th byte to
|
* so we use a big endian 64 bit unsigned integer centred on the 5th byte to
|
||||||
* cover a huge range of difficulty targets, though not all 256 bits' worth */
|
* cover a huge range of difficulty targets, though not all 256 bits' worth */
|
||||||
static void set_work_target(struct work *work, int diff)
|
static void set_work_target(struct work *work, double diff)
|
||||||
{
|
{
|
||||||
unsigned char rtarget[32], target[32];
|
unsigned char rtarget[32], target[32];
|
||||||
|
double d64;
|
||||||
uint64_t *data64, h64;
|
uint64_t *data64, h64;
|
||||||
|
|
||||||
h64 = diffone;
|
d64 = diffone;
|
||||||
h64 /= (uint64_t)diff;
|
d64 /= diff;
|
||||||
memset(rtarget, 0, 32);
|
h64 = d64;
|
||||||
data64 = (uint64_t *)(rtarget + 4);
|
|
||||||
*data64 = htobe64(h64);
|
if (h64) {
|
||||||
swab256(target, rtarget);
|
memset(rtarget, 0, 32);
|
||||||
|
data64 = (uint64_t *)(rtarget + 4);
|
||||||
|
*data64 = htobe64(h64);
|
||||||
|
swab256(target, rtarget);
|
||||||
|
} else {
|
||||||
|
/* Support for the classic all FFs just-below-1 diff */
|
||||||
|
memset(target, 0xff, 28);
|
||||||
|
memset(&target[28], 0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
if (opt_debug) {
|
if (opt_debug) {
|
||||||
char *htarget = bin2hex(target, 32);
|
char *htarget = bin2hex(target, 32);
|
||||||
|
|
||||||
|
4
miner.h
4
miner.h
@ -821,7 +821,7 @@ struct stratum_work {
|
|||||||
bool clean;
|
bool clean;
|
||||||
|
|
||||||
int merkles;
|
int merkles;
|
||||||
int diff;
|
double diff;
|
||||||
};
|
};
|
||||||
|
|
||||||
#define RECVSIZE 8192
|
#define RECVSIZE 8192
|
||||||
@ -966,7 +966,7 @@ struct work {
|
|||||||
char job_id[64];
|
char job_id[64];
|
||||||
char nonce2[64];
|
char nonce2[64];
|
||||||
char ntime[16];
|
char ntime[16];
|
||||||
int sdiff;
|
double sdiff;
|
||||||
|
|
||||||
bool gbt;
|
bool gbt;
|
||||||
char gbt_coinbase[512];
|
char gbt_coinbase[512];
|
||||||
|
34
util.c
34
util.c
@ -1131,17 +1131,17 @@ static bool parse_notify(struct pool *pool, json_t *val)
|
|||||||
|
|
||||||
static bool parse_diff(struct pool *pool, json_t *val)
|
static bool parse_diff(struct pool *pool, json_t *val)
|
||||||
{
|
{
|
||||||
int diff;
|
double diff;
|
||||||
|
|
||||||
diff = json_integer_value(json_array_get(val, 0));
|
diff = json_number_value(json_array_get(val, 0));
|
||||||
if (diff < 1)
|
if (diff == 0)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
mutex_lock(&pool->pool_lock);
|
mutex_lock(&pool->pool_lock);
|
||||||
pool->swork.diff = diff;
|
pool->swork.diff = diff;
|
||||||
mutex_unlock(&pool->pool_lock);
|
mutex_unlock(&pool->pool_lock);
|
||||||
|
|
||||||
applog(LOG_DEBUG, "Pool %d difficulty set to %d", pool->pool_no, diff);
|
applog(LOG_DEBUG, "Pool %d difficulty set to %f", pool->pool_no, diff);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -1266,24 +1266,20 @@ bool auth_stratum(struct pool *pool)
|
|||||||
sprintf(s, "{\"id\": %d, \"method\": \"mining.authorize\", \"params\": [\"%s\", \"%s\"]}",
|
sprintf(s, "{\"id\": %d, \"method\": \"mining.authorize\", \"params\": [\"%s\", \"%s\"]}",
|
||||||
swork_id++, pool->rpc_user, pool->rpc_pass);
|
swork_id++, pool->rpc_user, pool->rpc_pass);
|
||||||
|
|
||||||
/* Parse all data prior sending auth request */
|
|
||||||
while (sock_full(pool, false)) {
|
|
||||||
sret = recv_line(pool);
|
|
||||||
if (!parse_method(pool, sret)) {
|
|
||||||
clear_sock(pool);
|
|
||||||
applog(LOG_INFO, "Failed to parse stratum buffer");
|
|
||||||
free(sret);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
free(sret);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!stratum_send(pool, s, strlen(s)))
|
if (!stratum_send(pool, s, strlen(s)))
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
sret = recv_line(pool);
|
/* Parse all data in the queue and anything left should be auth */
|
||||||
if (!sret)
|
while (42) {
|
||||||
goto out;
|
sret = recv_line(pool);
|
||||||
|
if (!sret)
|
||||||
|
goto out;
|
||||||
|
if (parse_method(pool, sret))
|
||||||
|
free(sret);
|
||||||
|
else
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
val = JSON_LOADS(sret, &err);
|
val = JSON_LOADS(sret, &err);
|
||||||
free(sret);
|
free(sret);
|
||||||
res_val = json_object_get(val, "result");
|
res_val = json_object_get(val, "result");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user