Skip to content

Commit

Permalink
getwork: fix result bool value
Browse files Browse the repository at this point in the history
  • Loading branch information
tpruvot committed Feb 12, 2016
1 parent 3b06670 commit b604551
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 12 deletions.
5 changes: 4 additions & 1 deletion stratum/coind_submit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,12 @@ bool coind_submitwork(YAAMP_COIND *coind, const char *block)
if(!params) return false;

sprintf(params, "[\"%s\"]", block);
json_value *json_res = rpc_call(&coind->rpc, "getwork", params);
json_value *json = rpc_call(&coind->rpc, "getwork", params);
free(params);

if(!json) return false;
json_value *json_res = json_get_object(json, "result");

bool b = json_res && json_res->type == json_boolean && json_res->u.boolean;
json_value_free(json_res);

Expand Down
2 changes: 1 addition & 1 deletion stratum/json.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ typedef struct

typedef enum
{
json_none,
json_none = 0,
json_object,
json_array,
json_integer,
Expand Down
4 changes: 0 additions & 4 deletions stratum/rpc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,10 +278,6 @@ json_value *rpc_call(YAAMP_RPC *rpc, char const *method, char const *params)
if(s2-s1 > 2000)
debuglog("delay rpc_call %s:%d %s in %d ms\n", rpc->host, rpc->port, method, s2-s1);

if (!strcmp(method, "getwork")) {
return json;
}

if(json->type != json_object)
{
json_value_free(json);
Expand Down
7 changes: 1 addition & 6 deletions stratum/rpc_curl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,7 @@ json_value *rpc_curl_call(YAAMP_RPC *rpc, char const *method, char const *params
sprintf(message, "{\"method\":\"%s\",\"id\":\"%d\"}", method, ++rpc->id);

json_value *json = rpc_curl_do_call(rpc, message);
rpc_curl_close(rpc);

free(message);
if(!json) return NULL;
Expand All @@ -472,12 +473,6 @@ json_value *rpc_curl_call(YAAMP_RPC *rpc, char const *method, char const *params
if(s2-s1 > 2000)
debuglog("delay rpc_call %s:%d %s in %d ms\n", rpc->host, rpc->port, method, s2-s1);

rpc_curl_close(rpc);

if (!strcmp(method, "getwork")) {
return json;
}

if(json->type != json_object)
{
json_value_free(json);
Expand Down

0 comments on commit b604551

Please sign in to comment.