diff --git a/src/bitcoin.c b/src/bitcoin.c index 09c5839a..951e2d56 100644 --- a/src/bitcoin.c +++ b/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; } - res_ret = json_string_value(res_val); - if (!res_ret || !strlen(res_ret)) { - LOGWARNING("Got null string in result to getbestblockhash"); - goto out; + if (!json_is_true(res_val)) { + res_ret = json_string_value(res_val); + 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; } diff --git a/src/generator.c b/src/generator.c index c764177a..26035d35 100644 --- a/src/generator.c +++ b/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;