Browse Source

Clean up block solve notification and messages, sending a work restart immediately

master
Con Kolivas 11 years ago
parent
commit
6a753c149d
  1. 16
      src/bitcoin.c
  2. 7
      src/generator.c

16
src/bitcoin.c

@ -377,32 +377,30 @@ bool submit_block(connsock_t *cs, char *params)
bool ret = false; bool ret = false;
char *rpc_req; char *rpc_req;
int len; int len;
char *s;
len = strlen(params) + 50; len = strlen(params) + 50;
rpc_req = ckalloc(len); rpc_req = ckalloc(len);
sprintf(rpc_req, "{\"method\": \"submitblock\", \"params\": [\"%s\"]}\n", params); sprintf(rpc_req, "{\"method\": \"submitblock\", \"params\": [\"%s\"]}\n", params);
LOGWARNING("SUBMITTING: %s", rpc_req);
val = json_rpc_call(cs, rpc_req); val = json_rpc_call(cs, rpc_req);
if (!val) { if (!val) {
LOGWARNING("Failed to get valid json response to getbestblockhash"); LOGWARNING("Failed to get valid json response to submitblock");
return ret; return ret;
} }
res_val = json_object_get(val, "result"); res_val = json_object_get(val, "result");
if (!res_val) { if (!res_val) {
LOGWARNING("Failed to get result in json response to getbestblockhash"); LOGWARNING("Failed to get result in json response to submitblock");
goto out; goto out;
} }
if (!json_is_true(res_val)) {
res_ret = json_string_value(res_val); res_ret = json_string_value(res_val);
if (!res_ret || !strlen(res_ret)) { if (res_ret && strlen(res_ret)) {
LOGWARNING("Got null string in result to getbestblockhash"); LOGWARNING("SUBMIT BLOCK RETURNED: %s", res_ret);
goto out; goto out;
} }
}
LOGWARNING("BLOCK ACCEPTED! HASH: %s", params);
ret = true; ret = true;
out: out:
s = json_dumps(val, 0);
LOGWARNING("SUBMIT RESULT: %s", s);
free(s);
json_decref(val); json_decref(val);
return ret; return ret;
} }

7
src/generator.c

@ -21,6 +21,7 @@
static int gen_loop(proc_instance_t *pi, connsock_t *cs) static int gen_loop(proc_instance_t *pi, connsock_t *cs)
{ {
unixsock_t *us = &pi->us; unixsock_t *us = &pi->us;
ckpool_t *ckp = pi->ckp;
int sockd, ret = 0; int sockd, ret = 0;
char *buf = NULL; char *buf = NULL;
gbtbase_t gbt; gbtbase_t gbt;
@ -82,8 +83,10 @@ retry:
} }
} }
} else if (!strncasecmp(buf, "submitblock:", 12)) { } else if (!strncasecmp(buf, "submitblock:", 12)) {
LOGDEBUG("Submitting block data!"); LOGNOTICE("Submitting block data!");
submit_block(cs, buf + 12); if (submit_block(cs, buf + 12))
send_proc(&ckp->stratifier, "update");
/* FIXME Add logging of block solves */
} }
close(sockd); close(sockd);
goto retry; goto retry;

Loading…
Cancel
Save