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

7
src/generator.c

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

Loading…
Cancel
Save