|
|
@ -1135,6 +1135,19 @@ static void broadcast_ping(sdata_t *sdata); |
|
|
|
#define REFCOUNT_REMOTE 100 |
|
|
|
#define REFCOUNT_REMOTE 100 |
|
|
|
#define REFCOUNT_LOCAL 5 |
|
|
|
#define REFCOUNT_LOCAL 5 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Submit the transactions in node/remote mode so the local btcd has all the
|
|
|
|
|
|
|
|
* transactions that will go into the next blocksolve. */ |
|
|
|
|
|
|
|
static void submit_transaction(ckpool_t *ckp, const char *hash) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
char *buf; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(!ckp->generator_ready)) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
ASPRINTF(&buf, "submittxn:%s", hash); |
|
|
|
|
|
|
|
send_proc(ckp->generator,buf); |
|
|
|
|
|
|
|
free(buf); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Build a hashlist of all transactions, allowing us to compare with the list of
|
|
|
|
/* Build a hashlist of all transactions, allowing us to compare with the list of
|
|
|
|
* existing transactions to determine which need to be propagated */ |
|
|
|
* existing transactions to determine which need to be propagated */ |
|
|
|
static bool add_txn(ckpool_t *ckp, sdata_t *sdata, txntable_t **txns, const char *hash, |
|
|
|
static bool add_txn(ckpool_t *ckp, sdata_t *sdata, txntable_t **txns, const char *hash, |
|
|
@ -1161,7 +1174,15 @@ static bool add_txn(ckpool_t *ckp, sdata_t *sdata, txntable_t **txns, const char |
|
|
|
|
|
|
|
|
|
|
|
txn = ckzalloc(sizeof(txntable_t)); |
|
|
|
txn = ckzalloc(sizeof(txntable_t)); |
|
|
|
memcpy(txn->hash, hash, 65); |
|
|
|
memcpy(txn->hash, hash, 65); |
|
|
|
|
|
|
|
/* Get the data from our local bitcoind as a way of confirming it
|
|
|
|
|
|
|
|
* already knows about this transaction. */ |
|
|
|
|
|
|
|
txn->data = generator_get_txn(ckp, hash); |
|
|
|
|
|
|
|
if (!txn->data) { |
|
|
|
|
|
|
|
/* If our local bitcoind hasn't seen this transaction,
|
|
|
|
|
|
|
|
* submit it for mempools to be ~synchronised */ |
|
|
|
|
|
|
|
submit_transaction(ckp, data); |
|
|
|
txn->data = strdup(data); |
|
|
|
txn->data = strdup(data); |
|
|
|
|
|
|
|
} |
|
|
|
if (!local || ckp->node) |
|
|
|
if (!local || ckp->node) |
|
|
|
txn->refcount = REFCOUNT_REMOTE; |
|
|
|
txn->refcount = REFCOUNT_REMOTE; |
|
|
|
else |
|
|
|
else |
|
|
@ -1214,19 +1235,6 @@ static void send_node_transactions(ckpool_t *ckp, sdata_t *sdata, const json_t * |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/* Submit the transactions in node/remote mode so the local btcd has all the
|
|
|
|
|
|
|
|
* transactions that will go into the next blocksolve. */ |
|
|
|
|
|
|
|
static void submit_transaction(ckpool_t *ckp, const char *hash) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
char *buf; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (unlikely(!ckp->generator_ready)) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
ASPRINTF(&buf, "submittxn:%s", hash); |
|
|
|
|
|
|
|
send_proc(ckp->generator,buf); |
|
|
|
|
|
|
|
free(buf); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static void submit_transaction_array(ckpool_t *ckp, const json_t *arr) |
|
|
|
static void submit_transaction_array(ckpool_t *ckp, const json_t *arr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
json_t *arr_val; |
|
|
|
json_t *arr_val; |
|
|
@ -7146,11 +7154,7 @@ static void add_node_txns(ckpool_t *ckp, sdata_t *sdata, const json_t *val) |
|
|
|
continue; |
|
|
|
continue; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!add_txn(ckp, sdata, &txns, hash, data, false)) |
|
|
|
if (add_txn(ckp, sdata, &txns, hash, data, false)) |
|
|
|
continue; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Submit transactions if we haven't seen them before */ |
|
|
|
|
|
|
|
submit_transaction(ckp, data); |
|
|
|
|
|
|
|
added++; |
|
|
|
added++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|