diff --git a/src/bitcoin.c b/src/bitcoin.c index f369b78c..67fd5e47 100644 --- a/src/bitcoin.c +++ b/src/bitcoin.c @@ -383,7 +383,7 @@ char *get_txn(connsock_t *cs, const char *hash) } ASPRINTF(&rpc_req, "{\"method\": \"getrawtransaction\", \"params\": [\"%s\"]}\n", hash); - val = json_rpc_call(cs, rpc_req); + val = json_rpc_response(cs, rpc_req); dealloc(rpc_req); if (unlikely(!val)) { LOGWARNING("%s:%s Failed to get valid json response to get_txn", cs->url, cs->port); diff --git a/src/ckpool.c b/src/ckpool.c index ef0fcbb2..0974b44b 100644 --- a/src/ckpool.c +++ b/src/ckpool.c @@ -1,5 +1,5 @@ /* - * Copyright 2014-2016 Con Kolivas + * Copyright 2014-2017 Con Kolivas * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free @@ -911,6 +911,11 @@ json_t *json_rpc_call(connsock_t *cs, const char *rpc_req) return _json_rpc_call(cs, rpc_req, false); } +json_t *json_rpc_response(connsock_t *cs, const char *rpc_req) +{ + return _json_rpc_call(cs, rpc_req, true); +} + /* For when we are submitting information that is not important and don't care * about the response. */ void json_rpc_msg(connsock_t *cs, const char *rpc_req) diff --git a/src/ckpool.h b/src/ckpool.h index 7d152fe6..fdf001b3 100644 --- a/src/ckpool.h +++ b/src/ckpool.h @@ -360,6 +360,7 @@ char *_ckdb_msg_call(const ckpool_t *ckp, const char *msg, const char *file, co #define ckdb_msg_call(ckp, msg) _ckdb_msg_call(ckp, msg, __FILE__, __func__, __LINE__) json_t *json_rpc_call(connsock_t *cs, const char *rpc_req); +json_t *json_rpc_response(connsock_t *cs, const char *rpc_req); void json_rpc_msg(connsock_t *cs, const char *rpc_req); bool send_json_msg(connsock_t *cs, const json_t *json_msg); json_t *json_msg_result(const char *msg, json_t **res_val, json_t **err_val); diff --git a/src/stratifier.c b/src/stratifier.c index 706b30a9..833bd2c4 100644 --- a/src/stratifier.c +++ b/src/stratifier.c @@ -1631,6 +1631,8 @@ static bool rebuild_txns(ckpool_t *ckp, sdata_t *sdata, workbase_t *wb, json_t * /* See if we can find it in our local bitcoind */ data = generator_get_txn(ckp, hash); if (!data) { + txn_val = json_string(hash); + json_array_append_new(missing_txns, txn_val); ret = false; continue; } @@ -1646,10 +1648,11 @@ static bool rebuild_txns(ckpool_t *ckp, sdata_t *sdata, workbase_t *wb, json_t * txn->refcount = REFCOUNT_REMOTE; HASH_ADD_STR(sdata->txns, hash, txn); } else { - txn_val = json_string(hash); - json_array_append_new(missing_txns, txn_val); - ret = false; - free(data); + txn->refcount = REFCOUNT_REMOTE; + txn->seen = true; + JSON_CPACK(txn_val, "{ss,ss}", + "hash", hash, "data", txn->data); + json_array_append_new(txn_array, txn_val); } ck_wunlock(&sdata->workbase_lock); }