kanoi 11 years ago
parent
commit
d406fc3b5e
  1. 3
      src/ckpool.c
  2. 4
      src/ckpool.h
  3. 62
      src/stratifier.c

3
src/ckpool.c

@ -293,8 +293,9 @@ out:
}
/* As send_recv_proc but only to ckdb */
char *_send_recv_ckdb(const char *path, const char *msg, const char *file, const char *func, const int line)
char *_send_recv_ckdb(const ckpool_t *ckp, const char *msg, const char *file, const char *func, const int line)
{
const char *path = ckp->ckdb_sockname;
char *buf = NULL;
int sockd;

4
src/ckpool.h

@ -134,8 +134,8 @@ bool _send_proc(proc_instance_t *pi, const char *msg, const char *file, const ch
#define send_proc(pi, msg) _send_proc(pi, msg, __FILE__, __func__, __LINE__)
char *_send_recv_proc(proc_instance_t *pi, const char *msg, const char *file, const char *func, const int line);
#define send_recv_proc(pi, msg) _send_recv_proc(pi, msg, __FILE__, __func__, __LINE__)
char *_send_recv_ckdb(const char *path, const char *msg, const char *file, const char *func, const int line);
#define send_recv_ckdb(path, msg) _send_recv_ckdb(path, msg, __FILE__, __func__, __LINE__)
char *_send_recv_ckdb(const ckpool_t *ckp, const char *msg, const char *file, const char *func, const int line);
#define send_recv_ckdb(ckp, msg) _send_recv_ckdb(ckp, msg, __FILE__, __func__, __LINE__)
json_t *json_rpc_call(connsock_t *cs, const char *rpc_req);

62
src/stratifier.c

@ -401,6 +401,7 @@ static void purge_share_hashtable(int64_t wb_id)
/* FIXME This message will be sent to the database once it's hooked in */
static void send_workinfo(ckpool_t *ckp, workbase_t *wb)
{
char *msg, *dump, *buf;
char cdfield[64];
json_t *val;
@ -423,8 +424,17 @@ static void send_workinfo(ckpool_t *ckp, workbase_t *wb)
"createby", "code",
"createcode", __func__,
"createinet", "127.0.0.1");
char *dump = json_dumps(val, 0); LOGDEBUG("id.sharelog.json=%s",dump); dealloc(dump);
dump = json_dumps(val, 0);
json_decref(val);
ASPRINTF(&msg, "id.sharelog.json=%s", dump);
dealloc(dump);
buf = send_recv_ckdb(ckp, msg);
if (likely(buf)) {
LOGWARNING("Got workinfo response: %s", buf);
dealloc(buf);
} else
LOGWARNING("Got no workinfo response :(");
dealloc(msg);
}
static void add_base(ckpool_t *ckp, workbase_t *wb, bool *new_block)
@ -1178,10 +1188,11 @@ static user_instance_t *authorise_user(const char *workername)
return instance;
}
/* FIXME Send this to the database and parse the response to authorise a user
* and get paramters back */
/* FIXME: Send this to the database and parse the response to authorise a user
* and get parameters back */
static bool send_recv_auth(stratum_instance_t *client)
{
char *msg, *dump, *buf;
char cdfield[64];
json_t *val;
ts_t now;
@ -1200,8 +1211,17 @@ static bool send_recv_auth(stratum_instance_t *client)
"createby", "code",
"createcode", __func__,
"createinet", "127.0.0.1");
char *dump = json_dumps(val, 0); LOGDEBUG("id.authorise.json=%s",dump); dealloc(dump);
dump = json_dumps(val, 0);
json_decref(val);
ASPRINTF(&msg, "id.authorise.json=%s", dump);
dealloc(dump);
buf = send_recv_ckdb(client->ckp, msg);
if (likely(buf)) {
LOGWARNING("Got auth response: %s", buf);
dealloc(buf);
} else
LOGWARNING("Got no auth response :(");
dealloc(msg);
return true;
}
@ -1531,6 +1551,7 @@ static json_t *parse_submit(stratum_instance_t *client, json_t *json_msg,
const char *user, *job_id, *nonce2, *ntime, *nonce;
double diff, wdiff = 0, sdiff = -1;
enum share_err err = SE_NONE;
char *msg, *dump, *buf;
char idstring[20];
uint32_t ntime32;
char *fname, *s;
@ -1722,8 +1743,17 @@ out_unlock:
} else
LOGERR("Failed to fopen %s", fname);
/* FIXME : Send val json to database here */
s = json_dumps(val, 0); LOGDEBUG("id.sharelog.json=%s",s); dealloc(s);
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)) {
LOGWARNING("Got sharelog response: %s", buf);
dealloc(buf);
} else
LOGWARNING("Got no sharelog response :(");
dealloc(msg);
out:
if (!share) {
val = json_pack("{ss,si,ss,ss,si,ss,ss,so,si,ss,ss,ss,ss}",
@ -1741,8 +1771,17 @@ out:
"createcode", __func__,
"createinet", "127.0.0.1");
/* FIXME : Send val json to database here */
s = json_dumps(val, 0); LOGDEBUG("id.sharelog.json=%s",s); dealloc(s);
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)) {
LOGWARNING("Got sharelog response: %s", buf);
dealloc(buf);
} else
LOGWARNING("Got no sharelog response :(");
dealloc(msg);
LOGINFO("Invalid share from client %d: %s", client->id, client->workername);
}
return json_boolean(result);
@ -2138,6 +2177,7 @@ static void *statsupdate(void *arg)
const double nonces = 4294967296;
double sps1, sps5, sps15, sps60;
user_instance_t *instance, *tmp;
char *msg, *dump, *buf;
int64_t pplns_shares;
char fname[512] = {};
tv_t now, diff;
@ -2299,7 +2339,17 @@ static void *statsupdate(void *arg)
"createby", "code",
"createcode", __func__,
"createinet", "127.0.0.1");
dump = json_dumps(val, 0);
json_decref(val);
ASPRINTF(&msg, "id.stats.json=%s", dump);
dealloc(dump);
buf = send_recv_ckdb(ckp, msg);
if (likely(buf)) {
LOGWARNING("Got stats response: %s", buf);
dealloc(buf);
} else
LOGWARNING("Got no stats response :(");
dealloc(msg);
/* Update stats 4 times per minute for smooth values, displaying
* status every minute. */

Loading…
Cancel
Save