Browse Source

Support newer BTCDs that don't return segwit rules in GBT.

master
ckolivas 5 years ago
parent
commit
6a967c0c8a
  1. 20
      src/stratifier.c

20
src/stratifier.c

@ -1437,11 +1437,11 @@ static void gbt_witness_data(workbase_t *wb, json_t *txn_array)
* are serialised. */ * are serialised. */
static void block_update(ckpool_t *ckp, int *prio) static void block_update(ckpool_t *ckp, int *prio)
{ {
const char* witnessdata_check, *rule; const char *witnessdata_check;
json_t *txn_array, *rules_array;
sdata_t *sdata = ckp->sdata; sdata_t *sdata = ckp->sdata;
bool new_block = false; bool new_block = false;
int i, retries = 0; int i, retries = 0;
json_t *txn_array;
bool ret = false; bool ret = false;
txntable_t *txns; txntable_t *txns;
workbase_t *wb; workbase_t *wb;
@ -1465,19 +1465,10 @@ retry:
txns = wb_merkle_bin_txns(ckp, sdata, wb, txn_array, true); txns = wb_merkle_bin_txns(ckp, sdata, wb, txn_array, true);
wb->insert_witness = false; wb->insert_witness = false;
rules_array = json_object_get(wb->json, "rules");
if (rules_array) {
int rule_count = json_array_size(rules_array);
for (i = 0; i < rule_count; i++) {
rule = json_string_value(json_array_get(rules_array, i));
if (!rule)
continue;
if (*rule == '!')
rule++;
if (safecmp(rule, "segwit")) {
witnessdata_check = json_string_value(json_object_get(wb->json, "default_witness_commitment")); witnessdata_check = json_string_value(json_object_get(wb->json, "default_witness_commitment"));
if (likely(witnessdata_check)) {
LOGDEBUG("Default witness commitment present, adding witness data");
gbt_witness_data(wb, txn_array); gbt_witness_data(wb, txn_array);
// Verify against the pre-calculated value if it exists. Skip the size/OP_RETURN bytes. // Verify against the pre-calculated value if it exists. Skip the size/OP_RETURN bytes.
if (likely(witnessdata_check)) { if (likely(witnessdata_check)) {
@ -1485,9 +1476,6 @@ retry:
LOGERR("Witness from btcd: %s. Calculated Witness: %s", witnessdata_check + 4, wb->witnessdata); LOGERR("Witness from btcd: %s. Calculated Witness: %s", witnessdata_check + 4, wb->witnessdata);
} else } else
LOGNOTICE("Segwit rules returned but no default_witness_commitment to check witness data"); LOGNOTICE("Segwit rules returned but no default_witness_commitment to check witness data");
break;
}
}
} }
generate_coinbase(ckp, wb); generate_coinbase(ckp, wb);

Loading…
Cancel
Save