Browse Source

Properly request transactions we don't find in the local bitcoind and demote the message for failed get_txn to notice only.

master
Con Kolivas 8 years ago
parent
commit
750abcddb6
  1. 2
      src/bitcoin.c
  2. 7
      src/ckpool.c
  3. 1
      src/ckpool.h
  4. 11
      src/stratifier.c

2
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);

7
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)

1
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);

11
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);
}

Loading…
Cancel
Save