|
|
@ -1262,13 +1262,27 @@ share_diff(char *coinbase, const uchar *enonce1bin, const workbase_t *wb, const |
|
|
|
return diff_from_target(hash); |
|
|
|
return diff_from_target(hash); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* passthrough subclients have client_ids in the high bits */ |
|
|
|
|
|
|
|
static inline bool passthrough_subclient(const int64_t client_id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return (client_id > 0xffffffffll); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Note recursive lock here - entered with workbase lock held, grabs instance lock */ |
|
|
|
/* Note recursive lock here - entered with workbase lock held, grabs instance lock */ |
|
|
|
static void send_node_block(sdata_t *sdata, const char *enonce1, const char *nonce, |
|
|
|
static void send_node_block(sdata_t *sdata, const char *enonce1, const char *nonce, |
|
|
|
const char *nonce2, const uint32_t ntime32, const int64_t jobid, |
|
|
|
const char *nonce2, const uint32_t ntime32, const int64_t jobid, |
|
|
|
const double diff) |
|
|
|
const double diff, const int64_t client_id) |
|
|
|
{ |
|
|
|
{ |
|
|
|
stratum_instance_t *client; |
|
|
|
stratum_instance_t *client; |
|
|
|
ckmsg_t *bulk_send = NULL; |
|
|
|
ckmsg_t *bulk_send = NULL; |
|
|
|
|
|
|
|
int64_t skip; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Don't send the block back to a remote node if that's where it was
|
|
|
|
|
|
|
|
* found. */ |
|
|
|
|
|
|
|
if (passthrough_subclient(client_id)) |
|
|
|
|
|
|
|
skip = client_id >> 32; |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
skip = 0; |
|
|
|
|
|
|
|
|
|
|
|
ck_rlock(&sdata->instance_lock); |
|
|
|
ck_rlock(&sdata->instance_lock); |
|
|
|
if (sdata->node_instances) { |
|
|
|
if (sdata->node_instances) { |
|
|
@ -1283,8 +1297,12 @@ static void send_node_block(sdata_t *sdata, const char *enonce1, const char *non |
|
|
|
json_set_double(val, "diff", diff); |
|
|
|
json_set_double(val, "diff", diff); |
|
|
|
DL_FOREACH(sdata->node_instances, client) { |
|
|
|
DL_FOREACH(sdata->node_instances, client) { |
|
|
|
ckmsg_t *client_msg; |
|
|
|
ckmsg_t *client_msg; |
|
|
|
|
|
|
|
json_t *json_msg; |
|
|
|
smsg_t *msg; |
|
|
|
smsg_t *msg; |
|
|
|
json_t *json_msg = json_deep_copy(val); |
|
|
|
|
|
|
|
|
|
|
|
if (client->id == skip) |
|
|
|
|
|
|
|
continue; |
|
|
|
|
|
|
|
json_msg = json_deep_copy(val); |
|
|
|
client_msg = ckalloc(sizeof(ckmsg_t)); |
|
|
|
client_msg = ckalloc(sizeof(ckmsg_t)); |
|
|
|
msg = ckzalloc(sizeof(smsg_t)); |
|
|
|
msg = ckzalloc(sizeof(smsg_t)); |
|
|
|
msg->json_msg = json_msg; |
|
|
|
msg->json_msg = json_msg; |
|
|
@ -2438,12 +2456,6 @@ static stratum_instance_t *__recruit_stratum_instance(sdata_t *sdata) |
|
|
|
return client; |
|
|
|
return client; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* passthrough subclients have client_ids in the high bits */ |
|
|
|
|
|
|
|
static inline bool passthrough_subclient(const int64_t client_id) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return (client_id > 0xffffffffll); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Enter with write instance_lock held */ |
|
|
|
/* Enter with write instance_lock held */ |
|
|
|
static stratum_instance_t *__stratum_add_instance(ckpool_t *ckp, const int64_t id, |
|
|
|
static stratum_instance_t *__stratum_add_instance(ckpool_t *ckp, const int64_t id, |
|
|
|
const char *address, int server) |
|
|
|
const char *address, int server) |
|
|
@ -4896,7 +4908,8 @@ test_blocksolve(const stratum_instance_t *client, const workbase_t *wb, const uc |
|
|
|
|
|
|
|
|
|
|
|
process_block(ckp, wb, coinbase, cblen, data, hash, swap32, blockhash); |
|
|
|
process_block(ckp, wb, coinbase, cblen, data, hash, swap32, blockhash); |
|
|
|
|
|
|
|
|
|
|
|
send_node_block(sdata, client->enonce1, nonce, nonce2, ntime32, wb->id, diff); |
|
|
|
send_node_block(sdata, client->enonce1, nonce, nonce2, ntime32, wb->id, |
|
|
|
|
|
|
|
diff, client->id); |
|
|
|
|
|
|
|
|
|
|
|
JSON_CPACK(val, "{si,ss,ss,sI,ss,ss,sI,ss,ss,ss,sI,ss,ss,ss,ss}", |
|
|
|
JSON_CPACK(val, "{si,ss,ss,sI,ss,ss,sI,ss,ss,ss,sI,ss,ss,ss,ss}", |
|
|
|
"height", wb->height, |
|
|
|
"height", wb->height, |
|
|
|