|
|
@ -401,13 +401,13 @@ static void purge_share_hashtable(int64_t wb_id) |
|
|
|
/* FIXME This message will be sent to the database once it's hooked in */ |
|
|
|
/* FIXME This message will be sent to the database once it's hooked in */ |
|
|
|
static void send_workinfo(ckpool_t *ckp, workbase_t *wb) |
|
|
|
static void send_workinfo(ckpool_t *ckp, workbase_t *wb) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char *msg, *dump, *buf; |
|
|
|
|
|
|
|
char cdfield[64]; |
|
|
|
char cdfield[64]; |
|
|
|
json_t *val; |
|
|
|
json_t *val; |
|
|
|
|
|
|
|
char *buf; |
|
|
|
|
|
|
|
|
|
|
|
sprintf(cdfield, "%lu,%lu", wb->gentime.tv_sec, wb->gentime.tv_nsec); |
|
|
|
sprintf(cdfield, "%lu,%lu", wb->gentime.tv_sec, wb->gentime.tv_nsec); |
|
|
|
|
|
|
|
|
|
|
|
val = json_pack("{ss,si,ss,ss,ss,ss,ss,ss,ss,ss,si,so,ss,ss,ss,ss}", |
|
|
|
val = json_pack("{ss,sI,ss,ss,ss,ss,ss,ss,ss,ss,sI,so,ss,ss,ss,ss}", |
|
|
|
"method", "workinfo", |
|
|
|
"method", "workinfo", |
|
|
|
"workinfoid", wb->id, |
|
|
|
"workinfoid", wb->id, |
|
|
|
"poolinstance", ckp->name, |
|
|
|
"poolinstance", ckp->name, |
|
|
@ -424,17 +424,12 @@ static void send_workinfo(ckpool_t *ckp, workbase_t *wb) |
|
|
|
"createby", "code", |
|
|
|
"createby", "code", |
|
|
|
"createcode", __func__, |
|
|
|
"createcode", __func__, |
|
|
|
"createinet", "127.0.0.1"); |
|
|
|
"createinet", "127.0.0.1"); |
|
|
|
dump = json_dumps(val, 0); |
|
|
|
buf = json_ckdb_call(ckp, "sharelog", val); |
|
|
|
json_decref(val); |
|
|
|
|
|
|
|
ASPRINTF(&msg, "id.sharelog.json=%s", dump); |
|
|
|
|
|
|
|
dealloc(dump); |
|
|
|
|
|
|
|
buf = send_recv_ckdb(ckp, msg); |
|
|
|
|
|
|
|
if (likely(buf)) { |
|
|
|
if (likely(buf)) { |
|
|
|
LOGWARNING("Got workinfo response: %s", buf); |
|
|
|
LOGWARNING("Got workinfo response: %s", buf); |
|
|
|
dealloc(buf); |
|
|
|
dealloc(buf); |
|
|
|
} else |
|
|
|
} else |
|
|
|
LOGWARNING("Got no workinfo response :("); |
|
|
|
LOGWARNING("Got no workinfo response :("); |
|
|
|
dealloc(msg); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
static void add_base(ckpool_t *ckp, workbase_t *wb, bool *new_block) |
|
|
|
static void add_base(ckpool_t *ckp, workbase_t *wb, bool *new_block) |
|
|
@ -1192,10 +1187,10 @@ static user_instance_t *authorise_user(const char *workername) |
|
|
|
* and get parameters back */ |
|
|
|
* and get parameters back */ |
|
|
|
static bool send_recv_auth(stratum_instance_t *client) |
|
|
|
static bool send_recv_auth(stratum_instance_t *client) |
|
|
|
{ |
|
|
|
{ |
|
|
|
char *msg, *dump, *buf; |
|
|
|
|
|
|
|
char cdfield[64]; |
|
|
|
char cdfield[64]; |
|
|
|
bool ret = false; |
|
|
|
bool ret = false; |
|
|
|
json_t *val; |
|
|
|
json_t *val; |
|
|
|
|
|
|
|
char *buf; |
|
|
|
ts_t now; |
|
|
|
ts_t now; |
|
|
|
|
|
|
|
|
|
|
|
ts_realtime(&now); |
|
|
|
ts_realtime(&now); |
|
|
@ -1212,25 +1207,21 @@ static bool send_recv_auth(stratum_instance_t *client) |
|
|
|
"createby", "code", |
|
|
|
"createby", "code", |
|
|
|
"createcode", __func__, |
|
|
|
"createcode", __func__, |
|
|
|
"createinet", "127.0.0.1"); |
|
|
|
"createinet", "127.0.0.1"); |
|
|
|
dump = json_dumps(val, 0); |
|
|
|
buf = json_ckdb_call(client->ckp, "authorise", val); |
|
|
|
json_decref(val); |
|
|
|
|
|
|
|
ASPRINTF(&msg, "id.authorise.json=%s", dump); |
|
|
|
|
|
|
|
dealloc(dump); |
|
|
|
|
|
|
|
buf = send_recv_ckdb(client->ckp, msg); |
|
|
|
|
|
|
|
if (likely(buf)) { |
|
|
|
if (likely(buf)) { |
|
|
|
char *secondaryuserid, *response = alloca(128); |
|
|
|
char *secondaryuserid, *response = alloca(128); |
|
|
|
|
|
|
|
|
|
|
|
LOGWARNING("Got auth response: %s", buf); |
|
|
|
sscanf(buf, "is.%*d.%s", response); |
|
|
|
sscanf(buf, "id.%*d.%s", response); |
|
|
|
|
|
|
|
secondaryuserid = response; |
|
|
|
secondaryuserid = response; |
|
|
|
strsep(&secondaryuserid, "."); |
|
|
|
strsep(&secondaryuserid, "."); |
|
|
|
|
|
|
|
LOGWARNING("Got auth response: %s response: %s suid: %s", buf, |
|
|
|
|
|
|
|
response, secondaryuserid); |
|
|
|
if (!strcmp(response, "added")) { |
|
|
|
if (!strcmp(response, "added")) { |
|
|
|
client->secondaryuserid = strdup(secondaryuserid); |
|
|
|
client->secondaryuserid = strdup(secondaryuserid); |
|
|
|
ret = true; |
|
|
|
ret = true; |
|
|
|
} |
|
|
|
} |
|
|
|
} else |
|
|
|
} else |
|
|
|
LOGWARNING("Got no auth response :("); |
|
|
|
LOGWARNING("Got no auth response :("); |
|
|
|
dealloc(msg); |
|
|
|
|
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -1274,7 +1265,7 @@ static void stratum_send_diff(stratum_instance_t *client) |
|
|
|
{ |
|
|
|
{ |
|
|
|
json_t *json_msg; |
|
|
|
json_t *json_msg; |
|
|
|
|
|
|
|
|
|
|
|
json_msg = json_pack("{s[i]soss}", "params", client->diff, "id", json_null(), |
|
|
|
json_msg = json_pack("{s[I]soss}", "params", client->diff, "id", json_null(), |
|
|
|
"method", "mining.set_difficulty"); |
|
|
|
"method", "mining.set_difficulty"); |
|
|
|
stratum_add_send(json_msg, client->id); |
|
|
|
stratum_add_send(json_msg, client->id); |
|
|
|
} |
|
|
|
} |
|
|
@ -1560,10 +1551,9 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg, |
|
|
|
const char *user, *job_id, *nonce2, *ntime, *nonce; |
|
|
|
const char *user, *job_id, *nonce2, *ntime, *nonce; |
|
|
|
double diff, wdiff = 0, sdiff = -1; |
|
|
|
double diff, wdiff = 0, sdiff = -1; |
|
|
|
enum share_err err = SE_NONE; |
|
|
|
enum share_err err = SE_NONE; |
|
|
|
char *msg, *dump, *buf; |
|
|
|
char *fname, *s, *buf; |
|
|
|
char idstring[20]; |
|
|
|
char idstring[20]; |
|
|
|
uint32_t ntime32; |
|
|
|
uint32_t ntime32; |
|
|
|
char *fname, *s; |
|
|
|
|
|
|
|
workbase_t *wb; |
|
|
|
workbase_t *wb; |
|
|
|
uchar hash[32]; |
|
|
|
uchar hash[32]; |
|
|
|
int64_t id; |
|
|
|
int64_t id; |
|
|
@ -1751,21 +1741,15 @@ out_unlock: |
|
|
|
LOGERR("Failed to fwrite to %s", fname); |
|
|
|
LOGERR("Failed to fwrite to %s", fname); |
|
|
|
} else |
|
|
|
} else |
|
|
|
LOGERR("Failed to fopen %s", fname); |
|
|
|
LOGERR("Failed to fopen %s", fname); |
|
|
|
/* FIXME : Send val json to database here */ |
|
|
|
buf = json_ckdb_call(client->ckp, "sharelog", val); |
|
|
|
dump = json_dumps(val, 0); |
|
|
|
|
|
|
|
json_decref(val); |
|
|
|
|
|
|
|
ASPRINTF(&msg, "id.sharelog.json=%s", dump); |
|
|
|
|
|
|
|
dealloc(dump); |
|
|
|
|
|
|
|
buf = send_recv_ckdb(client->ckp, msg); |
|
|
|
|
|
|
|
if (likely(buf)) { |
|
|
|
if (likely(buf)) { |
|
|
|
LOGWARNING("Got sharelog response: %s", buf); |
|
|
|
LOGWARNING("Got sharelog response: %s", buf); |
|
|
|
dealloc(buf); |
|
|
|
dealloc(buf); |
|
|
|
} else |
|
|
|
} else |
|
|
|
LOGWARNING("Got no sharelog response :("); |
|
|
|
LOGWARNING("Got no sharelog response :("); |
|
|
|
dealloc(msg); |
|
|
|
|
|
|
|
out: |
|
|
|
out: |
|
|
|
if (!share) { |
|
|
|
if (!share) { |
|
|
|
val = json_pack("{ss,si,ss,ss,si,ss,ss,so,si,ss,ss,ss,ss}", |
|
|
|
val = json_pack("{ss,si,ss,ss,sI,ss,ss,so,si,ss,ss,ss,ss}", |
|
|
|
"method", "shareerror", |
|
|
|
"method", "shareerror", |
|
|
|
"clientid", client->id, |
|
|
|
"clientid", client->id, |
|
|
|
"secondaryuserid", client->secondaryuserid, |
|
|
|
"secondaryuserid", client->secondaryuserid, |
|
|
@ -1780,17 +1764,12 @@ out: |
|
|
|
"createcode", __func__, |
|
|
|
"createcode", __func__, |
|
|
|
"createinet", "127.0.0.1"); |
|
|
|
"createinet", "127.0.0.1"); |
|
|
|
/* FIXME : Send val json to database here */ |
|
|
|
/* FIXME : Send val json to database here */ |
|
|
|
dump = json_dumps(val, 0); |
|
|
|
buf = json_ckdb_call(client->ckp, "sharelog", val); |
|
|
|
json_decref(val); |
|
|
|
|
|
|
|
ASPRINTF(&msg, "id.sharelog.json=%s", dump); |
|
|
|
|
|
|
|
dealloc(dump); |
|
|
|
|
|
|
|
buf = send_recv_ckdb(client->ckp, msg); |
|
|
|
|
|
|
|
if (likely(buf)) { |
|
|
|
if (likely(buf)) { |
|
|
|
LOGWARNING("Got sharelog response: %s", buf); |
|
|
|
LOGWARNING("Got sharelog response: %s", buf); |
|
|
|
dealloc(buf); |
|
|
|
dealloc(buf); |
|
|
|
} else |
|
|
|
} else |
|
|
|
LOGWARNING("Got no sharelog response :("); |
|
|
|
LOGWARNING("Got no sharelog response :("); |
|
|
|
dealloc(msg); |
|
|
|
|
|
|
|
LOGINFO("Invalid share from client %d: %s", client->id, client->workername); |
|
|
|
LOGINFO("Invalid share from client %d: %s", client->id, client->workername); |
|
|
|
} |
|
|
|
} |
|
|
|
return json_boolean(result); |
|
|
|
return json_boolean(result); |
|
|
@ -2186,15 +2165,14 @@ static void *statsupdate(void *arg) |
|
|
|
const double nonces = 4294967296; |
|
|
|
const double nonces = 4294967296; |
|
|
|
double sps1, sps5, sps15, sps60; |
|
|
|
double sps1, sps5, sps15, sps60; |
|
|
|
user_instance_t *instance, *tmp; |
|
|
|
user_instance_t *instance, *tmp; |
|
|
|
char *msg, *dump, *buf; |
|
|
|
|
|
|
|
int64_t pplns_shares; |
|
|
|
int64_t pplns_shares; |
|
|
|
char fname[512] = {}; |
|
|
|
char fname[512] = {}; |
|
|
|
tv_t now, diff; |
|
|
|
tv_t now, diff; |
|
|
|
|
|
|
|
char *s, *buf; |
|
|
|
int users, i; |
|
|
|
int users, i; |
|
|
|
ts_t ts_now; |
|
|
|
ts_t ts_now; |
|
|
|
json_t *val; |
|
|
|
json_t *val; |
|
|
|
FILE *fp; |
|
|
|
FILE *fp; |
|
|
|
char *s; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
tv_time(&now); |
|
|
|
tv_time(&now); |
|
|
|
timersub(&now, &stats.start_time, &diff); |
|
|
|
timersub(&now, &stats.start_time, &diff); |
|
|
@ -2260,7 +2238,7 @@ static void *statsupdate(void *arg) |
|
|
|
fprintf(fp, "%s\n", s); |
|
|
|
fprintf(fp, "%s\n", s); |
|
|
|
dealloc(s); |
|
|
|
dealloc(s); |
|
|
|
|
|
|
|
|
|
|
|
val = json_pack("{si,sf,sf,sf,sf}", |
|
|
|
val = json_pack("{sI,sf,sf,sf,sf}", |
|
|
|
"Round shares", stats.round_shares, |
|
|
|
"Round shares", stats.round_shares, |
|
|
|
"SPS1m", sps1, |
|
|
|
"SPS1m", sps1, |
|
|
|
"SPS5m", sps5, |
|
|
|
"SPS5m", sps5, |
|
|
@ -2304,7 +2282,7 @@ static void *statsupdate(void *arg) |
|
|
|
|
|
|
|
|
|
|
|
reward = 25 * instance->pplns_shares; |
|
|
|
reward = 25 * instance->pplns_shares; |
|
|
|
reward /= pplns_shares; |
|
|
|
reward /= pplns_shares; |
|
|
|
val = json_pack("{si,si,sf,ss,ss,ss,ss,ss,ss}", |
|
|
|
val = json_pack("{sI,sI,sf,ss,ss,ss,ss,ss,ss}", |
|
|
|
"Accepted", instance->diff_accepted, |
|
|
|
"Accepted", instance->diff_accepted, |
|
|
|
"Rejected", instance->diff_rejected, |
|
|
|
"Rejected", instance->diff_rejected, |
|
|
|
"Est reward", reward, |
|
|
|
"Est reward", reward, |
|
|
@ -2348,17 +2326,12 @@ static void *statsupdate(void *arg) |
|
|
|
"createby", "code", |
|
|
|
"createby", "code", |
|
|
|
"createcode", __func__, |
|
|
|
"createcode", __func__, |
|
|
|
"createinet", "127.0.0.1"); |
|
|
|
"createinet", "127.0.0.1"); |
|
|
|
dump = json_dumps(val, 0); |
|
|
|
buf = json_ckdb_call(ckp, "stats", val); |
|
|
|
json_decref(val); |
|
|
|
|
|
|
|
ASPRINTF(&msg, "id.stats.json=%s", dump); |
|
|
|
|
|
|
|
dealloc(dump); |
|
|
|
|
|
|
|
buf = send_recv_ckdb(ckp, msg); |
|
|
|
|
|
|
|
if (likely(buf)) { |
|
|
|
if (likely(buf)) { |
|
|
|
LOGWARNING("Got stats response: %s", buf); |
|
|
|
LOGWARNING("Got stats response: %s", buf); |
|
|
|
dealloc(buf); |
|
|
|
dealloc(buf); |
|
|
|
} else |
|
|
|
} else |
|
|
|
LOGWARNING("Got no stats response :("); |
|
|
|
LOGWARNING("Got no stats response :("); |
|
|
|
dealloc(msg); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Update stats 4 times per minute for smooth values, displaying
|
|
|
|
/* Update stats 4 times per minute for smooth values, displaying
|
|
|
|
* status every minute. */ |
|
|
|
* status every minute. */ |
|
|
|