Browse Source

Send auth and share messages to ckdb

master
Con Kolivas 11 years ago
parent
commit
1debfd1f45
  1. 2
      sql/initid.sh
  2. 3
      src/ckpool.c
  3. 4
      src/ckpool.h
  4. 39
      src/stratifier.c

2
sql/initid.sh

@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
fldsep="`echo -e '\x02'`"
#

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);

39
src/stratifier.c

@ -1178,10 +1178,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 +1201,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 +1541,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 +1733,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 +1761,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);

Loading…
Cancel
Save