|
|
@ -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; |
|
|
|
} |
|
|
|
} |
|
|
|